Skip to content
This repository was archived by the owner on Oct 15, 2026. It is now read-only.

Don't use triton cache for CPU backend - #372

Merged
Brandon Myers (bmyerz0) merged 3 commits into
mainfrom
backend-cache-hardening
Oct 15, 2026
Merged

Brandon Myers (bmyerz0) merged 3 commits into
mainfrom
backend-cache-hardening

Conversation

@bmyerz0

@bmyerz0 Brandon Myers (bmyerz0) commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Security scans reveal that driver.py of the CPU backend executes code from the disk without checks on ownership, permissions, signature, or hash. An attacker could thereby enable arbitrary code execution by priming the cache.

Mitigation

Use ownership and permissions.

The CPU backend now builds and loads launchers from private temporary directories instead of reusing libraries from Triton’s shared disk cache. Generated artifacts are checked for ownership and file type, then made owner-read-only before loading; Windows support is removed to limit the burden of maintenance. Loaded modules are reused within each process, while a new process recompiles its launchers on first use.

Other changes

Another code injection vector is also mitigated.
launcher_src.replace(kernel_placeholder_name, kernel_name) potentially allows an attacker to use kernel_name to inject code into the generated source before compilation. Mitigate by checking that the name looks like an identifier.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Concurrent first launches can retain duplicate libraries, and fork-based workers can leave build artifacts behind.

2 open findings
What changed in this PR

Hardens CPU launcher loading by replacing Triton’s shared disk cache with private builds and process-local module reuse.

Changes:

  • Builds launchers in private directories and validates artifact ownership, type, and permissions.
  • Validates kernel names and removes Windows support.
  • Registers cleanup for retained build directories.
File Description
backend/​driver.py Adds private launcher builds, artifact checks, process-local reuse, and cleanup.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread backend/driver.py Outdated
Comment thread backend/driver.py Outdated
Register launcher directory cleanup with multiprocessing so worker processes remove their private build artifacts on exit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmyerz0
Brandon Myers (bmyerz0) enabled auto-merge (squash) October 15, 2026 19:57
@bmyerz0
Brandon Myers (bmyerz0) merged commit 050b93a into main Oct 15, 2026
4 checks passed
@bmyerz0
Brandon Myers (bmyerz0) deleted the backend-cache-hardening branch October 15, 2026 20:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants