An LLM input sanitiser.
Project description
peroxide
Peroxide is a simple LLM input sanitiser. It uses only standard Python libraries to minimise the chance of a supply chain attack. Peroxide does not prevent semantic prompt injection.
Currently, this library prevents the following methods of prompt injection
- Oversized input attacks - truncating input to a configurable maximum length (default 4000 characters) before any processing begins, preventing resource exhaustion
- HTML entity encoding attacks - decoding entities like
<,>,&before processing, preventing attackers from disguising control tokens as HTML-encoded strings - URL encoding attacks - recursively decoding percent-encoded strings
(e.g.
%5BINST%5D->[INST]), including double and triple encoded payloads (e.g.%2520->%20-> space), preventing attackers from layering encoding to survive single-pass decoders - Unicode lookalike attacks - normalising visually similar characters to their
canonical forms via NFKC (e.g.
[->[,/->/,fi->fi), and explicitly normalising slash lookalikes not covered by NFKC (e.g.∕U+2215,⧸U+29F8), preventing attackers from spelling out control tokens using lookalike characters that bypass string matching - Invisible character obfuscation - removing zero-width characters (U+200B–U+200F), directional formatting characters (U+202A–U+202E), and the byte order mark (U+FEFF) that attackers insert inside token strings to break pattern matching while remaining invisible to human reviewers
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
peroxide-1.0.0.tar.gz
(5.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file peroxide-1.0.0.tar.gz.
File metadata
- Download URL: peroxide-1.0.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
281b71d687ca82a0e02a11b3b8e7783d10240c7b28e98326df07a0ad9dbb2621
|
|
| MD5 |
7f494a75ff3212223660bfb77a02ef41
|
|
| BLAKE2b-256 |
636f7a460d7f4766567e76906ad7e755cce635d8bbce21c19052f1e4386cec23
|
File details
Details for the file peroxide-1.0.0-py3-none-any.whl.
File metadata
- Download URL: peroxide-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d23866bc01eef383056391f9ecfe430e58dc61279630b131f68f8b9d634abc5a
|
|
| MD5 |
11536f6cfc7eeac76462daa17dfb27b2
|
|
| BLAKE2b-256 |
a5f7a298b0f1ac9fced4e32c0790289480479cb4c0f9eabddda099382464f71a
|