Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.

rift

CI PyPI Python License

Find the rift between an LLM agent guard's parse and the executor's, before it runs.

An agent screens a dangerous action behind a guard: a check that decides if a command, path, URL, or SQL string is safe. The thing that actually runs it parses the same bytes differently. When they disagree, you hand them one input: the guard clears it, the executor runs it as the hazard. The model never touches that gap, so a perfectly aligned model does not close it. This is the agent-boundary cousin of HTTP request smuggling. The research calls the class Guardrail Desync.

rift reads a guard's source and tells you which side it is on, before you send a single payload.

  • DELEGATE: the guard routes its whole decision through the executor's own parser. It holds.
  • REIMPLEMENT: the guard decides on a hand-rolled view, a regex, a token blocklist, a lexical path check. There is a rift, and it is desync-prone.

That prediction is not a hunch. It is measured on a benchmark, corroborated on real deployed guards, and the underlying law is proved in Coq.

Install

pip install rift-desync

The distribution is rift-desync (the name rift was taken on PyPI); the import package and the command are both rift. Stdlib only for the core. The optional extras pull in real guard libraries you want to test.

rift scan imports and executes the guard module you point it at. That is by design, it has to call the guard to read its structure, but it means you should only run it on guard code you trust and installed yourself.

Quick start

Point it at a guard function and name the boundary it defends:

$ rift scan examples/shell_reimplement.py --boundary shell
guard    guard  (examples/shell_reimplement.py)
boundary shell
verdict  REIMPLEMENT
         the guard decides on a hand-rolled view, not the executor's parse.
         predicted DESYNC-PRONE: an input the guard admits can carry a
         differential the executor runs as a hazard.
$ rift scan examples/shell_delegate.py --boundary shell
verdict  DELEGATE
         the guard routes its whole decision through the executor's parser.
         predicted SAFE under the law (no hazard-relevant differential).

Boundaries: shell, url, path, sql, content. Write your guard as a function guard(x) -> bool (True means the guard admits x), or pass --guard NAME.

The fix: PEG

The repair is to stop re-implementing the parser. The Parse-Equivalence Gate runs the guard against every parse the executor could take and admits only when they all agree, so it inherits the executor's transforms by construction and cannot be out-enumerated.

$ rift peg

Against a canonicalize-then-bind comparator on the SSRF and content boundaries, PEG admits 0 of the hazards that ctb leaks, with no false positives:

ctb (finite canonicalizer): 5 hazardous input(s) ADMITTED (bypass).
PEG (no canonicalizer):     0 hazardous input(s) admitted; 0 benign wrongly rejected.

The leaks are three loopback short forms (127.1, 127.0.1, 0x7f.1, which inet_aton dials but a strict decoder rejects) and two Cyrillic confusables that NFKC does not fold.

The evidence

rift bench       # 140 guards, 22,732 comparisons: held-out phi +0.66 vs -0.05 naive baseline
rift field       # the predictor on 9 real pip-installable guards: 9 of 9, zero delegate-but-fall
rift peg         # PEG vs canonicalize-then-bind: ctb leaks 5, PEG admits 0, no false positives
rift proof       # the Coq law: 0 axioms, 8 closed proofs
rift reproduce   # all of the above in one pass (make reproduce)

Install the guard extras for the full field study: pip install "rift-desync[guards]".

  • Benchmark. On 140 built guards across 22,732 comparisons, the source-read delegate-vs-reimplement call separates safe from broken on held-out boundaries at phi +0.66, against -0.05 for a baseline that only asks whether a guard calls a parser at all. Delegate implies safe at precision 1.000, with zero delegating-but-unsafe guards.
  • Field study. The same structural call, applied to the real installed source of nine deployed guards (bleach, defusedxml, the MCP SDK, cli-mcp-server, validators, detect-secrets, guardrails-ai, presidio, NeMo Guardrails), agrees with each guard's independently measured disposition on 9 of 9, with zero delegate-but-fall, the only kind of case that would refute the law.
  • The law. Coq 8.18, no axioms, eight closed proofs. Delegating to the executor's parse is safe; a guard that maps a permitted and a forbidden request onto one value stays safe only by rejecting both; PEG covers the canonicalizer gap. coqc proofs/RIFT.v checks it green.

The predictor is deliberately fallible. The corpus includes guards that delegate to the wrong parser and re-implementers that hold only by being over-restrictive, and every off-diagonal case is reported rather than dropped. A predictor that scored 100% here would be a red flag, not a result.

Coordinated disclosure

This tool came out of breaking real shipped agents. Those findings are handled under coordinated disclosure with the maintainers. This repository contains the predictor, the gate, the benchmark, the studies, and the proof. It does not contain working exploit payloads for embargoed findings or any vendor-specific zero-day. Advisory identifiers and proofs-of-concept move through the vendors' own channels, not here.

License

Apache-2.0. See LICENSE.

Metadata

Release files for rift-desync 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rift-desync 0.1.0
File Size Uploaded Provenance Actions
rift_desync-0.1.0.tar.gz 98.2 kB Without provenance Details for rift_desync-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rift-desync 0.1.0
File Interpreter ABI Platform Actions
rift_desync-0.1.0-py3-none-any.whl Python 3 none any Details for rift_desync-0.1.0-py3-none-any.whl

Total release size: 203.1 kB

Release files / rift_desync-0.1.0.tar.gz

Download URL rift_desync-0.1.0.tar.gz
Size 98.2 kB
Tags Source
SHA-256 checksum
How to use checksums
26d657afc647b3898b373da146fb1de1e8b08b67a7d3319d23c3db25694ca262
BLAKE2b-256 checksum
How to use checksums
4e2dcfec64c21ff87393dcaa49cfa3a369cae5ceea9e9dc5e5edc7d7a49f9cd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / rift_desync-0.1.0-py3-none-any.whl

Download URL rift_desync-0.1.0-py3-none-any.whl
Size 104.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
063c590eae90646570996c54ce713f74ad2b09b52b11e45dfb0a785ce30676b7
BLAKE2b-256 checksum
How to use checksums
82230710bf2fad5b6572083a8f46211fcf71d607a41a8abc56db87940ecfd548
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Security for rift-desync 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page