Metadata-Version: 2.4
Name: peroxide
Version: 1.0.0
Summary: An LLM input sanitiser.
Author: Tolga Pasin
License: MIT License
        
        Copyright (c) 2026 tolgapasin
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/tolgapasin/peroxide
Keywords: peroxide,llm,sanitiser,injection,security
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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 `&lt;`, `&gt;`, `&amp;`
  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`), 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
