PyCache Trap exploits Python cache replacement to bypass seven Agent Skill scanners, with an attack success rate of 94–100%PyCache Trap: The Inspection-Execution Gap in Agent Skill Scanners
The authors propose PyCache Trap and EAV: on 100 Skills, the ASR of seven scanners is 94–100%, and EAV reduces it to 0%.
A third-party publisher controls the documentation, source code, scripts, and bundled cache of the submitted Skill, and cannot modify the scanner, agent model, interpreter, or sandbox. The main setting is placing visible source code and a compatible compiled cache in the same package; the agent receives a relevant task and can invoke local programs.
- Agent Skill scanners mainly inspect documentation and visible source code, but Python may load bundled bytecode caches that behave differently. The authors focus on the provenance verification gap between what is trusted at admission and what is actually executed at runtime.
- PyCache Trap fixes the cache body and only rewrites invocation wording according to scanner feedback, measuring admission and semantic recognition separately. EAV connects inspected content and runtime artifacts with a typed execution graph and checks cache provenance via trusted recompilation.
- On 100 Skills, PyCache Trap's ASR against the seven scanners is 94–100%, with semantic recognition at zero for all. EAV detected all 100 with source replacement, and achieved 92.8% Recall and 10.0% FPR on five attack classes and 200 benign Skills.
- The authors state that results are constrained by the fixed Skill queue, scanner configuration and Python runtime environment; unsupported dynamic imports and custom loading paths are left for review. Runtime confirmation covers only Cisco, ExecScan, HSS, SkillFortify, and the paper does not report the names of the rewriter and the language model used by EAV.
- Evaluated models
- CiscoHSSAuditorSlowMistVetterSkillFortifyExecScanEAV
- Benchmarks
- SkillScannerClawHubskill0.ioGitHubMalSkillBench
- Metrics
- ASRsemantic recognitionFPRPrecisionRecallF1Mismatch TPRAbstainp50/p95 latency
The researchers proposed PyCache Trap, which places malicious behavior in Python compiled caches paired with visible source code, so that the source code checked by scanners is inconsistent with the bytecode actually loaded at runtime. Across 100 Skills and seven scanners, the attack achieved a 94–100% attack success rate, and no scanner semantically identified the hidden behavior in the cache; the success rate against the execution-based scanner ExecScan was 94%. The authors also proposed execution-aware verification EAV, which connects instructions, scripts, imports, and runtime artifacts into a typed execution graph and uses trusted recompilation to compare cached bytecode, detecting all 100 cache-replacement samples with source code and achieving 92.8% Recall and 10.0% FPR across five attack families and 200 benign Skills. The code has been open-sourced on GitHub.
Why it was selectedThe paper reports attack success rates for cache replacement against seven Skill scanners and includes a reproducible defense implementation, suitable as a reference for teams doing Skill admission.
Related events and news
2 events · 2 news mentions
- This event's paper
PyCache Trap 利用字节码缓存绕过 Agent 技能扫描器
News that mentions this paper
Adversa AI 发布 11 月 Agent 技能安全资源汇编
- Adversa AIcites the paper's id or linkAgent 技能安全资源精选(2026 年 11 月)
PyCache trap: the inspection-execution gap in agent skill scanners
- 公众号 大模型安全研究cites the paper's id or link大模型安全周报:决策性模型护栏也能被攻击者绕过
2. 检查与执行的系统性缺口,技能扫描器被字节码绕过:PyCache Trap: The Inspection-Execution Gap in Agent Skill Scanners(https://arxiv.org/abs/2610.10612)
Paper analysis
What problem does this paper attempt to solve?
The authors study the provenance verification gap between the source code checked by Skill scanners and the cache actually executed by Python.
The core problem is: a scanner approving visible source code does not equal verifying the bytecode that the Python runtime actually selects.
- Problem scenario: Agent Skills package instructions, scripts and resources, and third-party content can influence local execution. The authors consider scanning before installation or invocation to constitute the trust boundary between publisher and runtime environment.
- Gaps in existing checks: existing scanners mainly check documentation, metadata and source code; Python's cache timestamp or hash checks only determine whether the cache can load, and do not prove that the cache body was compiled from the source code seen.
- Core observation: the authors formalize the problem as executable-provenance soundness: if a scanner admits, the runtime representation should belong to an executable body the scanner can reconstruct from its view. Cache replacement invalidates this condition, and requires neither a hash collision nor modification of the interpreter.
- Threat model:
- Goal: get a Skill containing a replaced cache admitted, and have the cache behavior execute in the relevant task invocation.
- Knowledge and control: the third-party publisher controls documentation, source code, scripts and bundled caches; in the adaptive protocol, scanner feedback can be observed.
- Capability boundary: cannot modify the scanner, agent model, interpreter or sandbox.
- Victim system: workflows that use a scanner for admission and then have a Python agent invoke the Skill's local programs.
- Paper's approach: proposes the attack evaluation PyCache Trap, recording package admission, semantic recognition and runtime confirmation separately; proposes the defense execution-aware validation (EAV), which brings runtime artifacts into the admission check via the execution graph and trusted recompilation.
What related research exists?
Related work covers Skill attacks, scanning and provenance verification, and Python cache poisoning.
Agent Skills and agent security
- Liu et al. (2026b), Schmotz et al. (2026): respectively measure security vulnerabilities in Skill repositories and prompt injection attacks embedded in Skill files.
- Jia et al. (2026a), Liu et al. (2026a): study closed-loop optimization of malicious instructions and Skill supply chain exploitation; Zhang et al. (2025), Ling et al. (2026), Kolluri et al. (2026) study untrusted input in planning and tool execution.
Scanning, hidden instructions and provenance verification
- Cisco AI Defense, Snyk, fedrov2025: respectively provide pattern and behavior analysis, agent/MCP scanning and permission review; Liu et al. (2026b), Ying et al. (2026) and Bhardwaj (2026) involve static and semantic auditing and capability verification.
- SkillCamo and ExecScan (Jia et al., 2026b): the former demonstrates image-hidden instructions, the latter handles this channel with multimodal analysis and execution simulation. The paper notes that recovering the visible call does not verify the bytecode body it selects.
- in-toto (Torres-Arias et al., 2019): attests the artifact production process; DAS Lab's package-level defense combines static anomaly detection with dynamic analysis.
Python caching and loading mechanisms
- Ohm et al. (2026): study cache poisoning from divergence between source and compiled artifacts in the Python ecosystem.
- Python import rules and PEP 552: govern cache selection and invalidation; the paper notes they do not establish executable provenance.
Comparison baselines and benchmarks
- Seven scanners: CISCO, HSS, AUDITOR, SLOWMIST, VETTER, SKILLFORTIFY, EXECSCAN, all from the SkillScanner benchmark.
- Attack controls: SkillJect, SkillCamo, SkillCamo-Cloze, SkillCamo-Split; uniformly using the same scanner versions, configuration, 100 clean-base Skills and blocking threshold (Table 1).
The authors position this paper as analyzing the executable artifact actually selected at runtime after Skill instructions trigger a call, and embed the provenance obligation of trusted recompilation into the execution graph.
How does the paper address this problem?
PyCache Trap fixes the cache body and adapts the wording; EAV verifies provenance via the execution graph and trusted recompilation.
The overall system consists of the attack evaluation PyCache Trap and the defense EAV: the former isolates the effect of wording on admission, and the latter places instructions, scripts, imports, and runtime artifacts into a single verification pipeline.
Problem Formalization and Attack Construction
- Package S contains documentation M, source code and scripts C, and other artifacts B; the scanner observes Vscan(S), and at runtime, under task u and configuration ρ, selects Eρ(S,u).
- The core definition is D(Vscan(S))=ACCEPT ⇒ Eρ(S,u)∈ Recon(Vscan(S)): admission must guarantee that the actual execution body belongs to the set the scanner can reconstruct.
- Each package pairs checkable source code with a runtime-compatible cache that behaves differently; a normally compiled cache from the same source serves as a negative control. A cache is selected as long as its header satisfies the loader's checks; the body need not come from visible source code.
- The invocation is preferentially placed in an existing script path; otherwise, a task-relevant entry point is added; among 100 Skills, 13 support the former. The authors note that task relevance does not guarantee preservation of the original task's utility.
Wording Adaptation Under Scanner Feedback
- The source/cache pair, load header, lazy import, entry-point naming, and invocation command are fixed; only the Skill description is edited, not the task.
- The optimization objective is minn∈ N,w∈ WJD(S′(n,w)), with the constraint cmd(w)=c0 and the execution body always b; J_D is the sum of severities found by the scanner, and the goal is to fall below the blocking threshold.
- The selector ranks candidate invocation nodes; the rewriter, based on the found category, severity, and snippet, rotates among four strategies: language softening, position shifting, narrative integration, and decoupling.
- Each node stops upon acceptance; after rejection, it rewrites at most κ=3 times before moving on, with a total budget of K=5 candidate iterations. Appendix E gives the complete rewriting prompt.
EAV: Execution Graph and Effect Projection
- Stage I: Build a typed execution graph whose nodes include instruction stages, scripts, source modules, caches, and effects; edges cover invocation, import, loading, and temporary-file or environment-variable channels.
- Invocation extraction, AST, and loader analysis resolve explicit invocations, unambiguous imports, and interpreter/failure modes; unresolved dynamic targets are retained as review items and are not treated as verified edges.
- Stage II: Project prose, code, image, and bytecode onto seven effect categories: read, write, net, exec, env, persist, and agent.
- Deterministic extraction handles explicit commands, reversible encodings, OCR commands, and bytecode constants/operations; language-model proposals are included only if they are grounded in source lines, verbatim quotations, operation sinks, and carrier symbols; ungrounded proposals are discarded.
Three Criteria and Contextual Determination
- Reachability: Propagate over graph node/taint-label pairs to a fixed point; sensitive reads or remote fetches produce labels, and reaching a release or execution sink forms a witness.
- Forbidden compositions: Check whether an ordered effect pattern is a subsequence of the graph path's effects, and detect the inherently harmful constructs enumerated by the authors; self-declared confirmation does not interrupt the check.
- Provenance closure: Require reachable artifacts to belong to the trusted set; a cache must be canonically equal to the recompilation result of its paired source under a matching interpreter. The comparison retains executable fields and recursive constant values, excludes file names and line tables; unsupported pairs are abstained on.
- Stage IV: The deployer separately holds retrieval and data-release allowlists, which package declarations cannot extend; scheme, host, and port are matched exactly. If any retained harmful criterion holds, it is judged HARMFUL; otherwise HARMLESS.
- Purpose review can revoke heuristic findings of legitimate service functionality, but cannot overturn high-confidence source evidence; a cache without source code yields a high-severity finding via the bytecode criterion. Appendix C gives the canonicalized fields, 16 retrieval sources, and the 0.55 risk threshold.
What experiments did the paper conduct?
The experiments separately measure admission, semantic recognition and runtime execution, and compare EAV's detection, compatibility and cost.
Experimental setup
- Attack corpus: 100 curated clean-base Skills from ClawHub, skill0.io and GitHub; PyCache Trap and four text/image attacks with 100 each, 500 candidates in total.
- Benign and compatibility: 200 benign Skills from official repositories and scanner-reviewed websites measure FPR; there are also 100 legitimate-cache fixtures covering seven compatibility cases.
- Systems under test: seven scanners CISCO, HSS, AUDITOR, SLOWMIST, VETTER, SKILLFORTIFY, EXECSCAN, plus the authors' defense EAV; the cache corpus targets Python 3.11.
- Metrics: ASR is the proportion of attack Skills not flagged, and any blocking warning counts as defense; semantic recognition requires the finding to point out the replaced cache, hidden behavior or carrying file, and merely mentioning the cache's existence does not count.
- Protocol: each candidate is queried once by the target scanner, with an adaptation budget of five candidates; semantic recognition checks stored findings against fixed written rules, and the paper does not report independent human review or agreement.
- Runtime experiments: Claude Code harness with MiniMax-M3, one agent trial per candidate; the joint result requires admission and a matching runtime signature on the same victim.
Main results
According to Table 1, values are ASR (%); the None row is the unflagged rate of 100 clean Skills, not ASR.
Swipe horizontally to read the table
Attack CISCO HSS AUDITOR SLOWMIST VETTER SKILLFORTIFY EXECSCAN EAV SkillJect 90 0 0 0 0 100 0 6 SkillCamo 100 87 92 78 87 100 8 11 SkillCamo-Cloze 40 33 39 55 60 64 31 9 SkillCamo-Split 54 20 48 42 43 97 17 10 PyCache Trap 95 95 100 100 100 96 94 0 - Semantic recognition: all seven baseline scanners are at zero on their respective 100 PyCache Trap Skills; the non-bypassed portion comes from cover text or generic warnings about the cache's existence.
- Adaptation process: Figure 4 reports cumulative ASR for one to five candidates, and the main text states ExecScan reaches 94% while EAV remains at 0%; the converted text does not preserve the per-point values of each curve.
- Authors' interpretation: the authors consider that, with the cache body fixed, rewriting the wording visible to the scanner can distinguish "blocking for any reason" from "recognizing the hidden executable body."
Runtime confirmation and cross-scanner transfer
- End-to-end results: in Table 2, Admitted for CISCO, EXECSCAN, HSS, SKILLFORTIFY is 95, 94, 95, 96 respectively; Admitted and executed is 77, 76, 83, 81 respectively, with denominators of 100 victims per scanner.
- Coverage exceptions: AUDITOR, SLOWMIST, VETTER have only scanner results, with no runtime confirmation collected; the cache bytes of all 100 victims in each queue remain unchanged.
- Transfer: Figure 5 uses 50 candidates per source and one target scan per cell. Baseline sources against CISCO are 94–100%, EXECSCAN 96–100%, SKILLFORTIFY 92–94%, HSS 10–62%; EAV detected all 350 baseline-source candidates.
- Reverse source: when EAV is the adaptation source, candidates' ASR against baseline targets is 50–100%, with HSS lowest at 50%; EAV self-test is 0%.
Defense detection, compatibility and mixed input
- Overall comparison: in Table 4, on 500 attack candidates and 200 benign Skills, EAV's FPR, Precision, Recall, F1 are 10.0%, 95.9%, 92.8%, 94.3% respectively; EXECSCAN's corresponding values are 37.5%, 82.4%, 70.0%, 75.7%.
- Per-family Recall: Appendix B.3 reports EAV's Recall on PyCache Trap, SkillJect, SkillCamo-Cloze, SkillCamo-Split, SkillCamo as 100.0%, 94.0%, 91.0%, 90.0%, 89.0% respectively, 464 detections in total.
- Provenance verification: in Table 3, header consistency's TPR on 100 with source replacement is 0.000; trusted reproduction and integrated EAV are both 1.000. bytecode-only semantics is also 1.000, but has an FPR of 0.170 on 100 legitimate caches.
- Compatibility cost: trusted reproduction accepts 86 checkable pairs and abstains on 14 source-less fixtures; deployed EAV rejects these 14 via the bytecode criterion, giving a 14% rejection rate over the full queue of legitimate caches. The 0.000 FPR in Table 3 applies only to the 86 checkable pairs.
- Heterogeneous input: on the 556-Skill MalSkillBench subset, full EAV's Precision, Recall, F1, FPR are 96.0%, 97.9%, 96.9%, 9.6% respectively.
Other ablations and analyses
- Criterion ablation: Appendix Table S3 fixes the graph and extracted findings; full criteria Recall/FPR is 93.0%/8.5%, and removing reachability gives 79.0%/3.5%.
- Remaining criteria: removing provenance closure gives Recall 92.8%; removing forbidden compositions or context both give 93.0%, which the authors attribute to criterion overlap on this corpus.
- Bytecode findings: removing them keeps Recall at 93.0%, with FPR dropping from 8.5% to 6.0%; five benign Skills without bundled caches trigger this signal because their documentation requires a setup script.
- Loader coverage: Appendix B.5 tests 50 fixtures for each of three configurations, with cache execution at 50/50 in all; in the source-less custom-hook cases trusted reproduction abstains entirely, and the graph does not resolve the loaded artifact.
- Remediation and cost: all 99 code-bearing packages can remove the replaced bytes by rebuilding the cache from checked source; in Table S2, EAV takes 15.6 s and 10,214 tokens per Skill, EXECSCAN 46.4 s and 12,389 tokens.
- Model information: the paper does not report the specific model versions of the wording rewriter, the EAV language model layer, and the three Claude-based scanners.
What are some points that can be further explored?
The authors limit the conclusions to the evaluated cohort and loaders; runtime confirmation and model information also have explicit boundaries.
Limitations and future directions noted by the authors
- Evaluation boundary: Appendix D explicitly states that the evaluation covers a fixed Skill queue, scanner configuration and Python runtime environment, and the reported numbers are constrained by these evaluated queues.
- Conservative reachability: Appendix D states that dynamic imports and custom loading paths outside the supported set are left for review rather than silently admitted.
- Endpoint execution boundary: Appendix C states that this policy is a static discovery policy; destination execution across redirects, DNS changes or unmodeled runtime behavior requires deployment-side egress control.
- Caches without source: Appendix D states that the fail-closed design rejects admission of bundled caches without checked source; this corresponds to the 14 legitimate source-less fixtures rejected in Table 3.
- Measurement scope: Appendix D states that runtime confirmation covers only CISCO, EXECSCAN, HSS, SKILLFORTIFY, and that transfer results are measured single-scan evaluations.
Experimental coverage
- Attack and defense queues: the main attack is 100 Skills × seven scanners; the defense comparison is 500 attack candidates across five families and 200 benign Skills (Table S1).
- Runtime and transfer: runtime experiments use 100 Skills for each of four admitting scanners, one agent trial per candidate; transfer uses 50 candidates per source and one target scan per cell (Table 2, Figure 5).
- Loaders and runtime environment: cache experiments target Python 3.11; namespace packages, importlib dynamic imports and custom sys.meta_path hooks are each tested with 50 fixtures (Appendix B.5).
- Adaptation budget: κ=3 per node, total budget K=5, one query per candidate per scanner; the paper does not report independent repeated scans or the number of runtime trials.
- Model and judgment information: the runtime backend is stated as MiniMax-M3; the paper does not report the names of the rewriter and the EAV language model layer, nor human agreement on the semantic recognition rules.
Summarize the main content of the paper
The paper uses cache substitution to test Skill admission and proposes EAV, which closes execution provenance via trusted recompilation.
This is an attack and defense study centered on Python Agent Skill scanning, focusing on the inconsistency between the visible source code approved by scanners and the bytecode actually loaded at runtime.
- Problem: The cache header check only determines whether loading is possible; it does not prove that the cache body comes from the inspected source code. Therefore, blocking caused by a generic warning cannot be equated with identifying hidden behavior.
- Attack design: PyCache Trap fixes the cache bytes, load header, imports, and commands, and only rewrites the documentation wording according to scanner feedback among at most five candidates, recording admission, semantic recognition, and runtime signature separately.
- Main attack results: On 100 Skills, the ASR of seven scanners is 94–100%, with EXECSCAN at 94%; all seven have zero semantic recognition of hidden cache behavior (Table 1).
- Runtime and transfer: Among 100 victims for each of four scanners, 76–83 are admitted and executed (Table 2); EAV detects all 350 baseline source-transfer candidates in a single scan.
- Defense design and results: EAV connects inspected content and runtime artifacts with a typed execution graph, combining reachability, forbidden compositions, and provenance closure. It detects all 100 source-code substitutions; on 500 attacks and 200 benign Skills, Recall is 92.8% and FPR is 10.0% (Tables 3, 4).
- Cost and boundaries: Trusted reproduction accepts 86 checkable legitimate pairs and abstains on 14 fixtures without source code; deploying EAV rejects the latter. The authors argue that, within the evaluated loaders and canonicalization scope, deterministic trusted recompilation can bear the provenance check; Appendix D limits the numbers to the fixed cohort, configuration, and Python runtime environment.