Skip to content

fix(security): detect multiline skill prompt injection - #117254

Merged
vincentkoc merged 2 commits into
openclaw:mainfrom
qingminglong:fix/multiline-skill-prompt-scan
Aug 1, 2026
Merged

vincentkoc merged 2 commits into
openclaw:mainfrom
qingminglong:fix/multiline-skill-prompt-scan

Conversation

@qingminglong

@qingminglong qingminglong commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users or automated Skill Workshop flows could submit a skill proposal whose prompt-injection wording was split across line breaks and have it treated as clean during apply.

Why This Change Was Made

The critical prompt-injection rules now treat whitespace, including line breaks, as part of the matched phrase. The shared source-rule matcher also records the actual starting line for cross-line findings, so stored scanner evidence points at the unsafe text rather than proposal frontmatter. The authoritative apply path remains unchanged: it rescans under the target lock and quarantines failed proposals before preparing or writing any workspace mutation.

User Impact

Multiline prompt-injection proposals are rejected and quarantined instead of being applied to the workspace. Operators also receive the correct source line and evidence for the detected text. Ordinary single-line detection remains covered by the existing rules and tests.

Evidence

Exact current head: 8e197068473696fcafcf9411e1fe68bb157f106b.

Sanitized direct AWS Crabbox proof:

  • Run: https://crabbox.openclaw.ai/portal/runs/run_cd07e01dc0ab
  • Fresh public-network AWS lease with no Tailscale state and no configured instance profile.
  • --fresh-pr openclaw/openclaw#117254, --no-hydrate, isolated temporary HOME, and CRABBOX_ENV_ALLOW=CI.
  • Trusted bootstrap verified the IMDSv2 IAM credentials endpoint returned 404 and the remote checkout matched the full expected head SHA.
  • pnpm exec oxfmt --check src/skills/security/scanner.ts src/skills/security/scanner.test.ts src/skills/workshop/service.test.ts - passed.
  • node scripts/run-vitest.mjs src/skills/security/scanner.test.ts - 37 passed.
  • node scripts/run-vitest.mjs src/skills/workshop/service.test.ts -t "quarantines multiline prompt-injection proposal text during apply" - 1 passed.
  • Trusted isolated Codex autoreview of the full branch diff - clean, with no accepted or actionable findings.

The Workshop service test proves the initial failed scan, apply rejection, durable quarantine state, and absence of the target SKILL.md. No external channel or provider is involved.

AI-assisted: yes. The author and maintainer understand the change and its behavior.

@qingminglong
qingminglong marked this pull request as ready for review August 1, 2026 06:04
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 4:56 AM ET / 08:56 UTC.

ClawSweeper review

What this changes

The PR makes Skill Workshop reject critical prompt-injection phrases split across whitespace or line breaks and records the line where each multiline match starts.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open for normal maintainer review. Current main still treats the affected critical phrases as same-line patterns, while this focused branch extends the existing full-content scanner and preserves the matched source location; no blocking correctness or supply-chain finding was identified.

Priority: P1
Reviewed head: 8e197068473696fcafcf9411e1fe68bb157f106b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, evidence-backed security repair with no blocking review finding; it is ready for ordinary maintainer review and normal exact-head checks.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body links exact-head sanitized Crabbox proof for the persisted Workshop proposal/apply path, including failed scan, quarantine, and absence of the target skill file.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body links exact-head sanitized Crabbox proof for the persisted Workshop proposal/apply path, including failed scan, quarantine, and absence of the target skill file.
Evidence reviewed 6 items Current-main gap: Current main uses literal spaces in the ignore/system rules and dot-based bounded matching for the tool rule, so line breaks prevent the reported phrases from matching.
Candidate repair: The PR uses whitespace-aware expressions for the phrase rules, permits bounded cross-line text for the approval-bypass rule, and derives a multiline finding line from the regex match offset.
Authoritative apply boundary: The existing apply transition rereads the proposal under its target lock, rescans the full bundle, and quarantines any non-clean scan before it prepares a workspace write.
Findings None None.
Security None None.

How this fits together

Skill Workshop scans a proposed skill and its support files before applying it to an operator workspace. The scanner supplies findings to the apply transition, which quarantines a proposal with a failed scan before any skill file is written.

flowchart LR
  A[Skill proposal and support files] --> B[Proposal content scan]
  B --> C[Critical injection-rule matching]
  C --> D{Scan clean?}
  D -->|No| E[Quarantine proposal]
  D -->|Yes| F[Prepare workspace mutation]
  F --> G[Write skill files]
Loading

Before merge

  • Complete next step (P2) - No mechanical repair is outstanding; maintainers should review the exact current head and land it when the normal merge checks complete.
Agent review details

Security

None.

PR surface

Source +9, Tests +64. Total +73 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 14 5 +9
Tests 2 64 0 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 78 5 +73

Review metrics

None.

Technical review

Best possible solution:

Land the focused scanner-and-Workshop regression repair after the exact current head has completed the normal merge checks, retaining the apply-time rescan and quarantine boundary as the single enforcement path.

Do we have a high-confidence way to reproduce the issue?

Yes—source establishes the path: current main scans the full proposal text with same-line-only critical expressions, so inserting line breaks prevents those phrases from matching; the branch adds focused regression coverage for that shape.

Is this the best way to solve the issue?

Yes—the scanner owns the detection invariant, while the existing apply transition already owns locked rescanning and quarantine; extending the scanner and preserving match location is narrower and safer than adding a second apply-time policy path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 41051fe37c7f.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body links exact-head sanitized Crabbox proof for the persisted Workshop proposal/apply path, including failed scan, quarantine, and absence of the target skill file.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body links exact-head sanitized Crabbox proof for the persisted Workshop proposal/apply path, including failed scan, quarantine, and absence of the target skill file.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Without this repair, a Skill Workshop proposal can bypass critical prompt-injection detection by splitting the prohibited wording across lines and reach the apply workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body links exact-head sanitized Crabbox proof for the persisted Workshop proposal/apply path, including failed scan, quarantine, and absence of the target skill file.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body links exact-head sanitized Crabbox proof for the persisted Workshop proposal/apply path, including failed scan, quarantine, and absence of the target skill file.

Evidence

What I checked:

  • Current-main gap: Current main uses literal spaces in the ignore/system rules and dot-based bounded matching for the tool rule, so line breaks prevent the reported phrases from matching. (src/skills/security/scanner.ts:234, 41051fe37c7f)
  • Candidate repair: The PR uses whitespace-aware expressions for the phrase rules, permits bounded cross-line text for the approval-bypass rule, and derives a multiline finding line from the regex match offset. (src/skills/security/scanner.ts:234, 8e1970684736)
  • Authoritative apply boundary: The existing apply transition rereads the proposal under its target lock, rescans the full bundle, and quarantines any non-clean scan before it prepares a workspace write. (src/skills/workshop/apply-transition.ts:196, 41051fe37c7f)
  • Regression coverage: The branch adds direct scanner coverage for three split-line critical phrases and an end-to-end Workshop service assertion for failed scan, apply rejection, durable quarantine, and no target SKILL.md. (src/skills/workshop/service.test.ts:1499, 8e1970684736)
  • Feature provenance: The scanner and Workshop apply implementation entered current main together in the feature-introducing commit; blame assigns the current content-rule block to that commit. (src/skills/security/scanner.ts:228, c13a0493aa10)
  • Current-main-only check: No commits changed the touched scanner or Workshop paths between the PR base and current main, and the PR head is not an ancestor of current main; the repair remains necessary and unshipped. (src/skills/security/scanner.ts:234, 41051fe37c7f)

Likely related people:

  • yetval: The initial scanner, proposal scan, and Workshop apply-transition files were introduced together by the commit that current blame assigns to the content-rule block. (role: feature introducer; confidence: high; commits: c13a0493aa10; files: src/skills/security/scanner.ts, src/skills/workshop/apply-transition.ts, src/skills/workshop/proposal-scan.ts)
  • vincentkoc: A repository member authored the follow-up commit that corrects multiline finding locations and stated that the exact-head repair proof was complete. (role: recent reviewer and branch repair author; confidence: high; commits: 8e1970684736; files: src/skills/security/scanner.ts, src/skills/security/scanner.test.ts, src/skills/workshop/service.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-01T06:39:42.626Z sha 4fda24efd1d61a873b2bd6910ade443ea6fd3bcb :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T08:21:45.870Z sha 9ff49ddcf9a891dd6bcc068a0beaf1a3acebe311 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T08:39:03.392Z sha 709025c2fc841be682e4d7bc691cdf88ef9e5f02 :: needs real behavior proof before merge. :: none

@vincentkoc vincentkoc self-assigned this Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 1, 2026
@vincentkoc
vincentkoc force-pushed the fix/multiline-skill-prompt-scan branch from 9ff49dd to 709025c Compare August 1, 2026 08:29
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 1, 2026
@vincentkoc
vincentkoc force-pushed the fix/multiline-skill-prompt-scan branch from 709025c to 8e19706 Compare August 1, 2026 08:44
@vincentkoc

Copy link
Copy Markdown
Member

Rank-up disposition: the repair lane is complete at 8e197068473696fcafcf9411e1fe68bb157f106b. The shared matcher now preserves multiline finding locations; exact-head sanitized AWS proof and full-branch Codex autoreview are clean. @clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 1, 2026
@vincentkoc
vincentkoc merged commit abe237c into openclaw:main Aug 1, 2026
203 of 215 checks passed
vincentkoc added a commit to Alix-007/openclaw that referenced this pull request Aug 1, 2026
* origin/main:
  fix(update): keep rolled-back Git installs runnable (openclaw#117294)
  refactor(ui): centralize chat outbox projections (openclaw#117284)
  fix(sessions): preserve target rows during legacy migration (openclaw#117272)
  fix(security): detect multiline skill prompt injection (openclaw#117254)
  fix(qa): lease credentials for Telegram startup proof (openclaw#116842)
  refactor(memory): unify session ingestion (openclaw#117293)
  fix(channels): strip internal tool text in Reef and Zalo Personal (openclaw#112621)
  fix(ui): keep newer Appearance choices after delayed theme imports [AI-assisted] (openclaw#117292)
  fix(inference): simplify lifecycle and preserve Codex tool identity (openclaw#117298)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* fix(security): detect multiline skill prompt injection

* fix(security): preserve multiline finding locations

---------

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main:
  fix(update): keep rolled-back Git installs runnable (openclaw#117294)
  refactor(ui): centralize chat outbox projections (openclaw#117284)
  fix(sessions): preserve target rows during legacy migration (openclaw#117272)
  fix(security): detect multiline skill prompt injection (openclaw#117254)
  fix(qa): lease credentials for Telegram startup proof (openclaw#116842)
  refactor(memory): unify session ingestion (openclaw#117293)
  fix(channels): strip internal tool text in Reef and Zalo Personal (openclaw#112621)
  fix(ui): keep newer Appearance choices after delayed theme imports [AI-assisted] (openclaw#117292)
  fix(inference): simplify lifecycle and preserve Codex tool identity (openclaw#117298)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants