Skip to content

feat(swift): differential-oracle lane (belief vs ground-truth confinement) - #71

Open
anagnorisis2peripeteia wants to merge 2 commits into
mainfrom
feat/differential-oracle-swift
Open

feat(swift): differential-oracle lane (belief vs ground-truth confinement)#71
anagnorisis2peripeteia wants to merge 2 commits into
mainfrom
feat/differential-oracle-swift

Conversation

@anagnorisis2peripeteia

Copy link
Copy Markdown
Owner

Summary

Ports the differential-oracle idea to compiled Swift. Instead of driving a payload through a code sink, it probes a target's own confinement decision function and diffs its belief (did it approve the input?) against ground truth (does materializing the approved path escape the sandbox base?). A control that approves a path whose write escapes has diverged from its own gate — belief=approved AND ground-truth=escaped.

Generic and extensible, not per-target (matches PLAYBOOK.md):

  • Auto-discovers String-first-arg decision functions (security-decision-verb names), capturing each one's body, throws-ness, and return type.
  • Gates fs-escape on a genuine boundary check in the body — a variable hasPrefix(base), contains(".."), or allowed-root/baseDir compare — not mere normalization (hasPrefix("/"), standardizedFileURL). This precision is deliberate: a normalizer with no containment contract has no belief to diverge from.
  • Leaves a strategy seam (exec-marker stub) for command/launch-approval gates.
  • Compiles the target file + a generated main.swift driver in isolation (like the other Swift lanes); a decision needing the rest of its package is an honest miss.

Canary

fixtures/differential-oracle-swift/vuln.swift — a naive hasPrefix-only confiner that approves a ../ / symlink escape. npm run validate:attacker reports the lane LIVE.

Runs

Target Swift files Decision candidates Divergence findings
Peekaboo 1,633 5 0 (confinement surface consistent)
CodexBar 1,617 6 0; surfaced launch-approval candidates (isLaunchCandidateAllowed, resolvedExecutablePath) — targets for the exec-marker strategy

An early run flagged a normalizer (ApplicationIdentifierResolver.resolve) — verified a false positive and tightened the classifier to require a real boundary check, per the family's no-false-positives rule.

Follow-ups (not in this PR)

  • Implement exec-marker so command/launch-approval gates (e.g. CodexBar's Gatekeeper gate) get driven.
  • Tighten discovery so incidental isApplicationRunning-style matches don't surface as candidates.

…finement)

Port the differential-oracle idea to compiled Swift: instead of driving a
payload through a sink, probe a target's own confinement DECISION function and
diff its BELIEF (does it approve the input?) against GROUND TRUTH (does
materializing the approved path escape the sandbox base?). A control that
approves a path whose write escapes has diverged from its own gate.

Generic and extensible, not per-target: auto-discovers String-first-arg decision
functions, gates fs-escape on a genuine boundary check in the body (a variable
hasPrefix / '..' / allowed-root compare, not mere normalization), and leaves a
strategy seam for exec-marker. Compiles the target file + a generated main.swift
driver in isolation. Ships a naive-confiner canary so the lane proves itself live.

Ran on Peekaboo (0 divergences; confinement surface consistent) and CodexBar
(0 divergences; surfaced launch-approval decision candidates for the exec lane).
Add the exec-marker ground-truth strategy: a command/launch-approval gate's
belief (does it approve?) vs ground truth (does running the approved input fire
the benign marker?). Drives Bool/throws gates named/bodied for exec, with a
planted marker executable so launch-path gates are probed with a real exec.
Ships a naive-command-approver canary.

Tighten fs-escape discovery to require a path return or path-ish name (not just
any Bool that incidentally matches a boundary pattern), removing isApplicationRunning-
style noise. Both canaries fire; validate:attacker LIVE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant