repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/leaks/README.md

Raw

leaks

Provider-bound secret redaction for Pi.

leaks replaces only high-confidence secret values before provider requests. Local Pi restores authenticated placeholders before tools and user-visible output.

Threat model

Provider payloads receive placeholders instead of classified values. Pi persists encrypted mappings in custom session entries so reload, resume, fork, and tree navigation can restore active-branch placeholders. The root key and ciphertext share the session file, so this is context isolation and obfuscation, not encryption at rest.

leaks is not DLP, a sandbox, or a permission system.

Placeholder model

__LEAK_V1_<TAG>[_<TAG>...]_<HMAC32>__

HMAC32 is derived from a random generation root key. Mappings use AES-256-GCM with a fresh nonce and authenticated generation metadata. A mapping must be durably appended before its placeholder can reach the provider. If Pi has not flushed first-turn session entries yet, that request remains visible and warns; later turns retry from durable session state without /reload. Persistence, encryption, collision, or capacity failure leaves the original value visible and warns.

Only authenticated mappings on sessionManager.getBranch() hydrate. Unknown current or legacy placeholders block every built-in and custom tool. write and edit targeting the leaks extension itself preserve literal placeholder fixtures without hydration so the extension remains maintainable. Cycles, unsupported objects, and traversal beyond depth 64 also block tools because inspection is incomplete.

Commands

The extension registers no tools. Non-UI diagnostics go to stderr with a [leaks] prefix.

Settings

Only custom regex rules are accepted.

{
  "leaks": {
    "regex": [{ "pattern": "foo_[A-Za-z0-9]{32}", "label": "FOO_TOKEN" }]
  }
}

Labels must match [A-Z0-9_]{1,64}. Invalid rules warn and are ignored or use the documented label fallback. Unsupported compatibility settings are rejected.

Detector policy

Precision outranks provider secrecy. Ambiguous values remain visible.

Structured formats require parsing or complete bounded context:

Dotenv discovery reads .env, .env.local, and .env.*.local under cwd. Public and metadata names remain visible unless the value has a provider-specific shape.

Property tests

Run the dedicated suite separately from unit tests:

mise run fuzz

Replay one detector property exactly:

FC_TEST=jwt-positive FC_SEED=123 FC_PATH='0:1' mise run fuzz

The runner force-kills the suite after two minutes and exits 124 on timeout. mise run ci includes this fuzz gate.

Limits

Mappings and learned values are capped at 8192 entries each. Secret-byte editing, images, audio, binary data, OCR, homomorphic transforms, repository cleanup, sandboxing, and permission enforcement are out of scope.

Markdown source
File outline
# leaks

Provider-bound secret redaction for Pi.

`leaks` replaces only high-confidence secret values before provider requests.
Local Pi restores authenticated placeholders before tools and user-visible output.

## Threat model

Provider payloads receive placeholders instead of classified values.
Pi persists encrypted mappings in custom session entries so reload, resume, fork, and tree navigation can restore active-branch placeholders.
The root key and ciphertext share the session file, so this is context isolation and obfuscation, not encryption at rest.

`leaks` is not DLP, a sandbox, or a permission system.

## Placeholder model

```text
__LEAK_V1_<TAG>[_<TAG>...]_<HMAC32>__
```

HMAC32 is derived from a random generation root key.
Mappings use AES-256-GCM with a fresh nonce and authenticated generation metadata.
A mapping must be durably appended before its placeholder can reach the provider.
If Pi has not flushed first-turn session entries yet, that request remains visible and warns; later turns retry from durable session state without `/reload`.
Persistence, encryption, collision, or capacity failure leaves the original value visible and warns.

Only authenticated mappings on `sessionManager.getBranch()` hydrate.
Unknown current or legacy placeholders block every built-in and custom tool.
`write` and `edit` targeting the `leaks` extension itself preserve literal placeholder fixtures without hydration so the extension remains maintainable.
Cycles, unsupported objects, and traversal beyond depth 64 also block tools because inspection is incomplete.

## Commands

- `/leaks status` reports safe counters and labels.
- `/leaks reload` rebuilds active-branch mappings and reloads settings and dotenv/environment learning.
- `/leaks test <text>` reports a local match count.
- `/leaks clear` appends a fresh generation after confirmation.

The extension registers no tools.
Non-UI diagnostics go to stderr with a `[leaks]` prefix.

## Settings

Only custom regex rules are accepted.

```json
{
  "leaks": {
    "regex": [{ "pattern": "foo_[A-Za-z0-9]{32}", "label": "FOO_TOKEN" }]
  }
}
```

Labels must match `[A-Z0-9_]{1,64}`.
Invalid rules warn and are ignored or use the documented label fallback.
Unsupported compatibility settings are rejected.

## Detector policy

Precision outranks provider secrecy.
Ambiguous values remain visible.

Structured formats require parsing or complete bounded context:

- JWTs require three canonical Base64URL segments, object header/payload JSON, and nonempty `alg`.
- URLs use `URL` and redact only parsed passwords and exact sensitive query values.
- Basic authorization requires canonical Base64 that decodes with a `:` separator.
- Cookie and assignment names use complete separator-aware tokens.
- PuTTY private payloads obey declared line counts and canonical Base64.
- Environment URLs learn only parsed password and sensitive query components.

Dotenv discovery reads `.env`, `.env.local`, and `.env.*.local` under cwd.
Public and metadata names remain visible unless the value has a provider-specific shape.

## Property tests

Run the dedicated suite separately from unit tests:

```console
mise run fuzz
```

Replay one detector property exactly:

```console
FC_TEST=jwt-positive FC_SEED=123 FC_PATH='0:1' mise run fuzz
```

The runner force-kills the suite after two minutes and exits 124 on timeout.
`mise run ci` includes this fuzz gate.

## Limits

Mappings and learned values are capped at 8192 entries each.
Secret-byte editing, images, audio, binary data, OCR, homomorphic transforms, repository cleanup, sandboxing, and permission enforcement are out of scope.