Because SecureCodeAudit ingests untrusted source code, archives, and potentially malicious repositories, the tool itself is a high-value attack surface. Every boundary below is explicitly mitigated in code and verified by automated pytest security tests.
| Threat ID | Vector / Attack | Mitigation Implemented | Verification Test |
|---|---|---|---|
| TM-01 | Arbitrary Code Execution via Uploaded setup.py / pyproject.toml / Tests |
Uploaded files are never imported (importlib), executed, or passed to pip / pytest. Dependency scanning parses manifests statically in Python (tomllib, json, packaging.requirements). |
test_inventory.py, test_analyzers.py |
| TM-02 | Zip-Slip / Path Traversal / Windows Reserved Filenames | sanitize_rel_path() rejects .., absolute paths, Windows drive letters (C:), UNC paths, null bytes, trailing spaces/dots, and Windows device names (CON, NUL, COM1..LPT9). Path.resolve().is_relative_to(sandbox) verified before every write. |
tests/test_ingest_security.py |
| TM-03 | Zip Bombs & Header Spoofing | Decompression streams through _stream_copy_checked() counting actual written bytes (never trusting ZipInfo.file_size or TarInfo.size), enforcing max_single_file_bytes, max_total_bytes, max_file_count, entry-count caps, and max_compression_ratio (50:1). Failed extractions delete partial sandboxes. |
tests/test_ingest_security.py |
| TM-04 | Symlink / Hardlink Escape | Rejects Unix S_ISLNK and Windows DOS reparse point (0x400) zip entries, tar SYMTYPE/LNKTYPE/special nodes, and sets followlinks=False during inventory walks. |
tests/test_ingest_security.py, tests/test_inventory.py |
| TM-05 | Untrusted Tool Config Sabotage (.bandit, .semgrepignore, .semgrep.yml) |
Bandit is invoked with an explicit controlled --ini outside the target dir; Semgrep runs --no-git-ignore --disable-version-check --metrics=off with rules strictly from scaudit's own rules/ directory and explicit file lists when <=250 files. |
tests/test_analyzers.py::test_bandit_ignores_malicious_target_ini |
| TM-06 | Command Injection in Subprocess Calls | All subprocess invocations use explicit list[str] argument vectors with shell=False and per-tool timeouts. |
scaudit/analyzers/base.py |
| TM-07 | Stored / Reflected XSS in Web UI & HTML Reports | Jinja2 autoescaping enabled; Pygments escapes code output cleanly; JSON <script type="application/json"> escapes <, >, &; sse.js uses .textContent instead of innerHTML; strict Content-Security-Policy: default-src 'self'; HTML reports escape every string with html.escape(). |
tests/test_reports.py, tests/test_web_api.py |
| TM-08 | CSRF & Remote Local-Filesystem Probe | Dashboard binds 127.0.0.1 only unless --allow-remote is explicitly passed (which prints a warning and disables /api/scans/local-path with 403). Mutating endpoints enforce SameSite=Strict cookie + X-CSRF-Token verification. |
tests/test_cli.py, tests/test_web_api.py |
| TM-09 | Secret Leakage in Logs, Reports, or SQLite DB | redact_text() masks tokens, keys, URI credentials, and passwords inside secrets_adapter, RedactingLogFilter, mappers, and ScanRepository.save_scan() before data ever hits SQLite or disk reports. |
tests/test_redact.py, tests/test_storage.py, tests/test_analyzers.py |