fix(dlp): prevent critical DLP bypass via HTTP compression - #152
Open
TANICE-GAWD wants to merge 1 commit into
Open
fix(dlp): prevent critical DLP bypass via HTTP compression#152TANICE-GAWD wants to merge 1 commit into
TANICE-GAWD wants to merge 1 commit into
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: Fix critical DLP bypass via HTTP compression
What this fixes
DLP is ClawShell's last line of defense against leaking sensitive data. It scans
request and response bodies and blocks or redacts PII. The problem: it scanned the
raw bytes and nothing decoded gzip. So an attacker could hide the payload inside a
compressed body and walk it straight past DLP, in plain sight.
What could go wrong if left unfixed
This is a full bypass of ClawShell's core security control, and it is trivial to
weaponize. One HTTP header disarms DLP completely. Worse, the attacker is the exact
threat DLP exists to stop: the agent, which can be hijacked by prompt injection,
and which already holds a valid virtual key.
Accept-Encoding: gzip. Theprovider replies gzipped, DLP scans the scrambled bytes, sees nothing, and hands
it back. The attacker's client unzips it and reads every SSN, card number, and
secret DLP was supposed to catch.
Content-Encoding: gzipwith agzipped body. DLP sees noise, waves it through, and the payload leaks upstream
past every block rule.
It failed open and silent. No error, no log, no trace in
/admin/stats. A breachhere would leave nothing behind to find.
Why the old code was vulnerable
filter_hop_by_hop_headersinsrc/proxy.rsforwarded the attacker'saccept-encodingandcontent-encodingheaders untouched, and reqwest does notdecode gzip. So the scanner never saw anything but ciphered bytes.
The fix
Force DLP to always see plain text. The fix deliberately does not unzip attacker
controlled data, since decompressing untrusted input on a privileged process opens
a zip bomb hole. It shuts the compression down instead.
accept-encoding: identityon every request sent upstream, so theprovider is not allowed to reply compressed.
Content-Encodingwith400.with
502instead of trusting unscanned bytes.Testing
Added six tests, all passing. They confirm identity is forced upstream, compressed
requests are rejected with
400, and compressed responses fail closed with502.Per CONTRIBUTING.md:
cargo testpasses (356 + 16 tests).cargo fmtandcargo clippy --all-targetsare clean. No config changed, so no snapshots toupdate.
Note
The URL query string is still not scanned by DLP and remains a separate hole,
out of scope for this change. This PR closes the compression bypass only.