Skip to content

feat(code-injection): report import directories chosen by input - #256

Merged
SizzleUnrlsd merged 1 commit into
mainfrom
feat/import-path-sinks
Oct 14, 2026
Merged

SizzleUnrlsd merged 1 commit into
mainfrom
feat/import-path-sinks

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

Part 2 of #240, first change: the import path. getattr(...)() follows in its own PR.

Summary

New sinks:

  • sys.path.insert (second argument; the index is data), sys.path.append, sys.path.extend and site.addsitedir (sitedir) are CODE sinks with selects. Only a check that limits the directory to constants proves them.

How findings are reported:

  • sys.path.* → hotspot, Untrusted import path: code runs only when a later import resolves to a module the attacker placed there.
  • site.addsitedir → vulnerability, Untrusted site directory: the import lines of the directory's .pth files run during the call. The evidence states the condition: exploitable when the directory holds files the attacker controls.
  • The environment and the command line reach these sinks, following the existing source policy.

Coverage is partial, as documented in docs/usage.md: writes to sys.path that are not calls (slice assignment, +=, rebinding) are not reported.

Verification

  • tests/test_import_path_sinks.py, new: 23 tests; the 12 positive cases fail on main. They cover:

    • every sink and its argument;
    • non-directory arguments;
    • shape checks (hotspot);
    • constant checks (refuted);
    • environment and command line.

    No existing test changed.

  • Full suite green, apart from the local test_packaging metadata issue. ruff check and mypy clean. Regression snapshots unchanged; no new finding on mitmproxy or healthchecks.

Part of #240: sys.path and site.addsitedir. getattr follows in its own change.
@SizzleUnrlsd SizzleUnrlsd added the enhancement New feature or request label Oct 14, 2026
@SizzleUnrlsd SizzleUnrlsd self-assigned this Oct 14, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit a758e1f into main Oct 14, 2026
10 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the feat/import-path-sinks branch October 14, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant