Skip to main content
Loss of provenance

A previous release had provenance metadata, but this release does not. View details.

gamai-tripwire

Where this fits. One stack, one order. gama-mandate is the product: it signs a business commitment, executes it once and proves it offline. Everything else is a layer you add only when you need what it does:

layer install what it adds
gamai-tripwire pip install gamai-tripwire inbound detection from access logs: canaries, bursts, credential reuse; a deny needs identity evidence
gamai-guard pip install gamai-guard prompt-injection filter: lexical + multilingual embeddings, block / advise bands
sigil-profile pip install sigil-profile proof-carrying execution profile over MCP/A2A: gate, verify, anchor
proofgate-runtime pip install proofgate-runtime small claim-verification and signed-receipt core
gama-l pip install gama-l a small language with types, effects and proofs
gamai-trust pip install gamai-trust trust marketplace and managed policy evaluation
gamai-plugins pip install gamai-plugins MCP plugins: policy, sandbox, team

None of these is a compliance certificate, a tamper-proof guarantee or an independent audit; each README says what it does not claim.

Detect automated and agent-like behaviour inbound from an access log — planted canaries, spec-derived novel paths, tool switching, key probing — and refuse to blame what the evidence does not support.

What it cannot do: it does not tell an AI agent from any other script. A Python httpx loop and a coding agent look the same in a log, and claiming otherwise would be a stronger statement than the data supports. What it can say is that a client behaved like an automated one, with the evidence, and block only when the evidence is cumulative (see docs/FALSE_POSITIVES.md).

One day of this site's own traffic, and the address column that hid the scanners behind a tunnel: docs/REAL_TRAFFIC.md (7,975 requests, 1,251 clients after XFF resolution).

Built from the November 2026 incident in which an attacker used an open-source coding agent, a browser and curl against a financial firm: no blocklist matched the address, and the only reliable signal was behaviour — a desktop browser that switched to a fake phone user-agent, then to curl, from one address inside a few minutes; a request for a path that existed only inside an API document served seconds earlier; the same key, no key and a fabricated key tried against one endpoint within seconds.

mandate watch (in gama-mandate) scores those behaviours. This package adds what an inbound detector needs and an authorisation log cannot give:

  1. Planted canaries — credential-shaped strings that no legitimate client ever sends. Any use is decisive on its own.
  2. Spec-derived novel paths — a path whose first appearance follows a fetch of an API/spec document within 60 s, one path per document.
  3. Credential and probe rules — five rejected credentials on one endpoint in a minute, twenty-five distinct paths answering 4xx, forty distinct paths in a minute whatever the status.
  4. Corroboration — the two document rules only count when the same address also failed an auth check. Reading the spec is not an attack; failing the check right after is. This is the discriminator the incident report named.
  5. A deny list you can actually apply — nginx lines plus JSON with an expiry per entry, and loopback/private addresses are never blocked.

Install

pip install gamai-tripwire      # pulls gama-mandate for the base rules + ledger

Which mandate version the numbers below need. The two document rules count only when the same session produced two rejections; that condition lives in gama-mandate and landed after 1.0.59. With gama-mandate==1.0.59 (the newest release on 2026-12-03) the benign document rules fire on 137 of 360 sessions instead of 0. The corpus numbers on this page are therefore a property of the pair; docs/REPRODUCIBLE.md says how CI pins the reviewed commit until the release catches up.

Python 3.9+, no services, no model, no network calls at analysis time.

Plant canaries

tripwire canary generate --count 3 --registry canaries.json \
        --plant-dir /var/www/decoy    # writes decoy docs containing the tokens
# prints the tokens ONCE; only their sha256 is stored
tripwire canary list     --registry canaries.json
tripwire check --token tw_xxx --registry canaries.json      # exit 0 = planted
tripwire canary revoke --id 3f9c1a2b4d5e --registry canaries.json

Put one token in each place an intruder reads: a decoy API document, a sample .env, a runbook, a Git history you know is scraped. A leaked registry does not leak the tokens, so an attacker cannot learn what to avoid.

Watch an access log

tripwire watch --log access.jsonl --registry canaries.json --window 600 \
               --ledger alerts.jsonl --min-level medium \
               --deny-map out/deny.map --deny-json out/deny.json --deny-ttl 3600

Exit code 0 = nothing at or above --min-level, 1 = something is. Findings are appended to the mandate ledger as {"type":"control","action":"alert"} in the same hash chain as execution receipts, so an alert is evidence too.

Formats. --format auto (default) detects the file: our JSONL, or the combined format that nginx and Apache write by default. Combined logs carry no credential value, so the two credential rules need the JSONL schema.

JSONL line, one per request:

{"ts": 1795558000.1, "ip": "81.2.3.4", "ua": "Mozilla/5.0 ... Chrome/157",
 "method": "GET", "path": "/api/v1/invoices", "status": 200,
 "ua_platform": "desktop", "auth": "key-A", "referer": "/docs/api.md", "query": ""}

For nginx: log_format ... escape=json gives this shape directly; a combined log needs no change at all.

Behind a CDN or a load balancer every request arrives from the proxy, so the peer address is not the client. Either let nginx resolve it (set_real_ip_from <proxy>; real_ip_header X-Forwarded-For; — then combined already carries the real client), or include xff in the JSONL line and name the proxy:

tripwire watch --log access.jsonl --trusted-proxy 10.0.0.0/16 --trusted-proxy 104.16.0.0/13

A prefix shorter than /16 (IPv4) or /48 (IPv6) is refused with exit 2, because 10.0.0.1/8 trusts every 10.x address and an attacker may reach the proxy port. Pass --allow-wide-proxy only when you really own that range.

X-Forwarded-For from an address you did not list is ignored and recorded as xff_ignored, because otherwise anyone can pick someone else's address and get that address blocked.

Deny list. --deny-map writes deny <ip>; lines with a comment per entry carrying expires=<epoch>; --deny-json writes the same as data. It merges with the file already on disk (an unexpired block survives a quiet minute), drops expired entries, replaces the file atomically, refuses to grow past --deny-max (default 1000 — a huge list costs nginx throughput), and runs --reload-cmd only after a good write. Apply the list from your edge; the tool never rewrites firewall state itself. Three gates before an address is blocked:

  1. Global unicast only — loopback, RFC1918, link-local and documentation ranges are skipped and reported: blocking them takes the service down.
  2. Identity, not behaviour — denial needs a canary, probed or rejected credentials, or one credential used across several addresses with a failure ratio. Behaviour (ua_flip, tool_switch, velocity, path_burst) only alerts: a laptop, a phone and one curl script behind a shared NAT look exactly like an intruder. --deny-unsafe opts into volume-based blocking.
  3. Expiry in the file — a cron that re-runs watch both adds and removes.

--ignore <ip> (repeatable) keeps your own scanner out.

A scan spread across many addresses. Per-address rules cannot see it. Keep a per-path history and the endpoint's own baseline catches it:

tripwire watch --log access.jsonl --window 600 \
        --baseline /var/lib/tripwire/baseline.json --baseline-factor 3 --baseline-floor 10

Anomalies are reported per path, not per address. A one-off window is not folded into the history; if it repeats for two consecutive windows it is folded in (0.2 EWMA), so a path cannot alert forever. It needs a few clean runs first; a cold path is never an alarm.

Not shouting every minute. A cron that re-runs watch over the same file needs --state:

tripwire watch --log access.jsonl --state /var/lib/tripwire/state.json --state-ttl 3600
# output: new_alerts=0 when nothing changed; an escalation is new again

The state file keeps the last level per address with an expiry, is pruned on every write and is replaced atomically.

Rotation. .gz files are read directly, so access.log.1.gz needs no unpacking step.

Time. The window is measured against the newest row in the file, not the wall clock, so a log written yesterday is still analysed. --now wall for live tailing, --now <epoch> for a fixed cut-off. An empty or unparsable file exits 3 and says no rows — it never reports "clean".

Rules and weights

rule points what it sees
canary_used 10 a planted key was sent — critical on its own
path_baseline_anomaly report a path whose distinct-source count is 3x its own history (needs --baseline)
key_across_addresses 3–6 one credential from 3+ addresses and 5+ rejected requests (6 when 6+ addresses or 20+ rejections)
key_probing 4 3+ distinct auth values (or none) on one path within 60 s
auth_failure_streak 4 5+ rejected credentials on one endpoint within 60 s
auth_failure_burst 4 5+ rejections in 60 s across 2+ paths and 2+ credentials (defeats path rotation)
slow_scan_multiua 2 10+ 4xx paths with 2+ user agents and a 4xx share >= 50 %
distributed_path_probe 3 (6) one path failing from 3+ addresses with 2+ distinct credentials, 25 % failure share
spec_derived_novel_path 3 first request to a path right after a spec fetch (needs two 401/403/404 in the session)
docs_link_follow 3 request whose Referer is an API/spec document (needs two 401/403/404 in the session)
read_after_submit 2 repeated GETs refused by submit-only endpoints
ua_flip 2 same address claims desktop and mobile within 5 min
path_burst 3 40+ distinct paths in 60 s, whatever the status (search bots excluded)
param_burst 3 200+ requests to the same path in 120 s (catches ?id=1..500 enumeration)
wide_probe 2 25+ distinct paths answering 4xx
tool_switch 2 browser then curl/wget/httpx from one address within 15 min
low_and_slow_scan 2 10+ paths answering 4xx with a single UA
velocity 1 15+ distinct paths in one minute

Levels: critical (canary), high (>=6), medium (>=3), else low. spec_derived_novel_path and docs_link_follow count only when the same address produced two 401/403/404 in the window. One rejection is a key that expired while the developer was reading the docs (the most common benign case); two is a probe. 140 of 360 benign sessions in our corpus read the docs, and none of them produces two rejections. GAMA_DOCS_MODE / GAMA_SPEC_MODE (legacy) reproduce the pre-2026-12-03 behaviour for corpus comparisons.

Replay the reported sequence and watch the score grow request by request:

python3 tools/replay.py
# t+29s  GET /api/v1/transactions  200  10  high
# first high: t+29s — a replay scored after the fact, not a live block

Measured, not asserted

python3 tools/gen_corpus.py --out corpus --benign 360 --attack 80 --seed 20261125
python3 tools/measure.py --corpus corpus
corpus result
360 benign sessions (adds a service that shares one working key across 4 egress addresses) 0 at medium or higher; 51/360 score tool_switch=2 at low (alert, never deny)
80 attack sessions (adds a key rotated across 8 addresses) 64 high, 80 medium or higher
shared address pool (tools/pool_swap.py: benign and attack on the same /24, 64 addresses carry both) 0/360, 64 high, 80 medium+ - identical, so nothing keys on the address range
held-out corpus, different seed (771122), same 360/80 split 0 at medium or higher, 64 high, 80 medium+ — identical to the tuning seed
baseline: "any 401 in the session" (one line, no rules) 0/360 benign, 64/80 attacks — see docs/BENCHMARK.md; the 18 rules add the 16 attacks that never produce a 401
this server's nginx log, 2026-11-24 run (snapshot not committed - the figure is an operator measurement, reproducibility unverified): 4,048 requests, 238 sources 5 flagged >= medium, 0 inspected and shown benign, 3 confirmed WordPress probing + a 770-path scanner
100,000 requests from one address on one path, one key 1.87 s analyse with tools/bench.py's generator (ips=1, paths=1) after the 2026-12-03 data_volume fix; 300k rows / 10k sources is 7.2 s. The old O(sessions x rows) loop made both of these minutes

Method, per-family tables and the four changes the measurement forced (including tool_switch dropping from 3 to 2 because it flagged 50 of 300 benign sessions) are in docs/FALSE_POSITIVES.md. Re-running the two commands reproduces every number.

Files bigger than memory

--stream keeps only the sources inside the window instead of the whole file. The same rules run; a correlation that spans two chunks can be lost (documented below). Measured on 2026-11-26, 100,000 rows / 200 sources inside a 600 s window:

mode window peak RSS time
--stream --chunk 200000 600 s 146 MB 2.46 s

Memory is bounded by rows in the window (roughly 1.5 KB each), not by the file or the source count: 100,000 rows measured 148.7 MB with one source and 146.6 MB with 200 sources - the source count barely moves it. The extreme case is measured too: 500,000 rows, each a distinct source, is 1.1 GB peak RSS and 27 s analyse - which is exactly why --max-sources (default 200,000) refuses the window instead of half-scoring it, and why chunked streaming exists.

tripwire watch --log access.log --stream --window 600 --chunk 200000

A source-rotating flood is refused, not half-scored. The deny list is validated by nginx -t in the test suite (tests/test_nginx.py). The build is pinned and content-reproducible (0 of 14 wheel files differ on a rebuild; the published 0.9.8 container bytes differ only by zip timestamps): docs/REPRODUCIBLE.md, and the release workflow rebuilds each tag and compares the bytes with PyPI (tools/verify_pypi.py).

--max-sources (default 200,000) is the point where a window cannot be scored honestly: the run stops, writes nothing to the ledger, and exits 3 with TooManySources instead of dropping the excess and reporting "clean". Raise it only with the RAM to match.

--chunk rows are scored together and the findings are unioned per source, with points taking the maximum. A chunk boundary can lose a timing correlation between two rules; it cannot invent one. rows_in_window, invalid_rows and xff_ignored in the output tell you what was actually scored.

Run it every minute

install -m 0755 packaging/tripwire-apply-nginx.sh /usr/local/sbin/
cp packaging/tripwire-watch.* packaging/tripwire-apply.* /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now tripwire-watch.timer tripwire-apply.path

The watch unit is unprivileged and writes the list to /var/lib/tripwire; the root oneshot apply unit tests the list with nginx -t and rolls back if it is bad. The window is the memory, so a timer gives tail-like coverage without a daemon. Exit codes are part of the contract: 0 nothing at or above --min-level, 1 findings, 3 could not analyse (missing/unparsable log, or every row outside the window/future-dated), 4 refused (explicit canary registry missing or unreadable, deny cap hit, deny list not writable). Deployment shape, ledger rotation, measured throughput and what is deliberately missing are in docs/OPERATIONS.md.

Tests

python -m pytest -q tests/

208 tests collected (2 need nginx; they skip where it is absent): the reported timeline scores high with all four decisive rules; a canary in the same log is critical; a developer switching to curl stays low; a doc reader without a failed check is suppressed; one document unlocks one path; a redirect-heavy scan is caught without any 4xx; a search bot is not a burst; loopback is never denied; volume evidence alone never denies; a log from yesterday is still analysed; combined and JSONL logs agree.

Detection benchmark

tools/detbench.py reports false positives at a fixed recall, on a seeded corpus and a held-out seed, plus latency and one unlabelled real log (docs/BENCHMARK.md). At the 95 % recall target (level ≥ medium, out/detbench.json): 80/80 attacks, 0/360 benign, 0/360 on the held-out seed, p50 0.31 ms per session; the real log flags 7 of 604 sessions (1.16 %) and that is a flag rate, not a false-positive rate.

What this is not

Where this sits in the standards. OWASP Agentic ASI02 (tool misuse) and ASI10 (rogue agents) are the closest categories; the detector works on access logs after the fact. No public benchmark exists for log-side agent detection that we could find, so the numbers here are ours and say so.

  • Not a WAF and not inline. It reads logs after the fact; blocking is the --deny-map file plus your edge.
  • Not TLS-inspecting. If the edge only logs CONNECT, there is nothing to score.
  • Not a model. No ML and no LLM in the decision path; a judge may explain a finding, never lower it.
  • Canaries only work if planted, and it will fire on your own scanners unless you --ignore them.
  • Not a certificate. It is evidence that a detection ran.
  • A patient attacker with a valid key who never fails an auth check looks like a developer. Documented limit; per-path baselines are future work.

Licence

MIT. Part of the gamAI control set: gama-mandate (signed approval of an effect), gamai-guard (prompt-injection), gamai-trust (claim vs evidence), gamai-plugins (policy/sandbox), crossnode-bench (false success).

Metadata

Release files for gamai-tripwire 0.9.9

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

Loss of provenance

These files do not have provenance metadata, despite files in a prior release including this data.

We recommend further investigation before installing these files. View details.

Source distribution (sdist)

Source distribution for gamai-tripwire 0.9.9
File Size Uploaded Provenance Actions
gamai_tripwire-0.9.9.tar.gz 139.6 kB Without provenance Details for gamai_tripwire-0.9.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gamai-tripwire 0.9.9
File Interpreter ABI Platform Actions
gamai_tripwire-0.9.9-py3-none-any.whl Python 3 none any Details for gamai_tripwire-0.9.9-py3-none-any.whl

Total release size: 182.2 kB

Release files / gamai_tripwire-0.9.9.tar.gz

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL gamai_tripwire-0.9.9.tar.gz
Size 139.6 kB
Tags Source
SHA-256 checksum
How to use checksums
98622c274354fe30b80b921fa78c915a7c84cf61e4678ee3fbc8a89876797e24
BLAKE2b-256 checksum
How to use checksums
a9feb0b74a95696f96c41a6dc5d1d414c409da1754321bbc54370d815f451db7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / gamai_tripwire-0.9.9-py3-none-any.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL gamai_tripwire-0.9.9-py3-none-any.whl
Size 42.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6430370c872ee3b555593faadc3599e7a9d29d158594e544afa54863602ff8e
BLAKE2b-256 checksum
How to use checksums
aafa49f0c93be0b627c5e86dc00ae09e4c66c030789deef89504482ccfee5126
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for gamai-tripwire 0.9.9

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.

Loss of provenance

A previous release of these files had provenance metadata, but this release does not.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Release comparison

  • Removed 0.9.7 2 files With provenance
  • Added 0.9.9 2 files Without provenance

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.9.9 This release

2 release files Loss of 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