Skip to main content

tool-result-taint-py

PyPI Python License: MIT

Track untrusted tool output before it enters prompts or actions. Tag any value that came back from an LLM tool call as "tainted", carry that taint through your pipeline, and refuse to use it in a sensitive context until you've explicitly reviewed and unwrapped it. Zero runtime dependencies.

Python port of @mukundakatta/tool-result-taint.

Install

pip install tool-result-taint-py

Usage

from tool_result_taint import (
    mark_tainted,
    is_tainted,
    taint_aware_dict,
    taint_report,
    unwrap_trusted,
)

# Wrap raw tool output before it enters your prompt-building pipeline.
result = mark_tainted("balance: $4321.00", source="bank.get_balance")

is_tainted(result)        # True
result.value              # "balance: $4321.00"
result.source             # "bank.get_balance"

# Audit a batch of inputs (mix tainted + plain).
report = taint_report([result, "trusted-system-prompt"])
report.safe               # False
report.tainted            # [{"source": "bank.get_balance", "value": "..."}]

# Refuse to use a tainted value in a sensitive context.
try:
    unwrap_trusted(result)
except RuntimeError:
    pass  # Caller must explicitly review or sanitize first.

unwrap_trusted("plain trusted string")     # "plain trusted string"

# Wrap a dict so every entry is tainted automatically.
taint_aware_dict({"name": "Alice", "ssn": "XXX-XX-1234"}, source="crm.lookup")
# -> {"name": Tainted("Alice"), "ssn": Tainted("XXX-XX-1234")}

API

Symbol Behavior
mark_tainted(value, source) Wraps value in a Tainted record stamped with source.
is_tainted(value) True for any Tainted record (or dict with tainted=True).
taint_aware_dict(mapping, source) Returns a new dict with each entry wrapped via mark_tainted.
taint_report(inputs) Aggregates a list of inputs into TaintReport(safe, tainted).
unwrap_trusted(value) Returns the raw value; raises if is_tainted(value).

See the JS sibling's README for the full design notes.

Metadata

Release files for tool-result-taint-py 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 tool-result-taint-py 0.1.0
File Size Uploaded Provenance Actions
tool_result_taint_py-0.1.0.tar.gz 6.3 kB Without provenance Details for tool_result_taint_py-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tool-result-taint-py 0.1.0
File Interpreter ABI Platform Actions
tool_result_taint_py-0.1.0-py3-none-any.whl Python 3 none any Details for tool_result_taint_py-0.1.0-py3-none-any.whl

Total release size: 12.3 kB

Release files / tool_result_taint_py-0.1.0.tar.gz

Download URL tool_result_taint_py-0.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2027b6314cc28e9ef551836450574ca3a58e4984bc801e77b6bb347855aef061
BLAKE2b-256 checksum
How to use checksums
2432359ff5f84a995e98acb985523dee9bf754538d05d4a7131a1521523d6d0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

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

Download URL tool_result_taint_py-0.1.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2299357ca1f833463e50c4839cc9f63e12f24c2c3efb5ff616ac36ce31569812
BLAKE2b-256 checksum
How to use checksums
c4e47e43e2824fbe4900eb13fb4b44e96ba5de09c5949b4087868de045a9cb05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for tool-result-taint-py 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