Skip to content

fix: security hardening from 2026-08-25 review - #1

Merged
NDilanka merged 16 commits into
mainfrom
cursor/security-hardening-plan-347b
Aug 25, 2026
Merged

NDilanka merged 16 commits into
mainfrom
cursor/security-hardening-plan-347b

Conversation

@NDilanka

@NDilanka NDilanka commented Aug 25, 2026 •

Copy link
Copy Markdown
Owner

Closes the 2026-08-25 whole-repo security review findings, executed in waves per docs/security-hardening-plan.md.

Also adds a host-matrix (test/host-matrix.test.ts) that checks envseal still works with every documented coding agent: doctor tiers, plugin MCP/CLI snippets, live envseal-mcp tools/list (stdio + Claude bundled CJS), SDK dialects, and HTTP OpenAPI.

Wave 1

  • H1–H3 / S2: Claude Code PreToolUse denies source/. of .env, unwraps env -i / busybox, fail-closed when shell nesting exceeds MAX_PAYLOAD_DEPTH (internal-error fail-open default unchanged).
  • H6 protocol: SEP_PATTERN_UNSAFE, SEP_KEYS_MISSING; format.pattern must be bounded / linearish.
  • H7/H8: Detector no longer drops high-entropy JSON values; bounded registry patterns used as high-confidence rules.
  • S8–S11: Actions pinned to commit SHAs; release lint --max-warnings 0; tag required for manual publish; example-demo probe before publish.

Wave 2

  • H4: Darwin keychain still uses security add-generic-password -w (stdin is ignored and stored an empty password on macos-latest). Linux/Windows keep stdin/pipe. Residual documented in docs/residual-risks.md.
  • H5: loadManifest scans raw JSONC (including comments).
  • H9: Broker.onRevokeConfirm required before any sink.remove.
  • H10/H11: dotenv write outside git requires .gitignore covering .env; POSIX chmod 0600 after replace.
  • H12: env_use refuses undeclared/missing keys; no partial injection.
  • S7: Registry verify.url must be https://; provider patterns bounded {n,256}.

Wave 3

  • MCP, SDK, HTTP, CLI wire revoke confirmation (no ENVSEAL_ASSUME_YES on agent bindings; CLI --yes remains human-only).
  • S3: HTTP token is ephemeral unless ENVSEAL_PERSIST_HTTP_TOKEN=1 or ~/.envseal/api-token already exists.
  • S5/S1: envseal doctor uses inspectDotenvGitSafety and reports hook fail-open vs fail-closed.
  • S6: Probe headlines run escapeForDisplay on key names.

Wave 4

  • PreToolUse denies Read of env.schema.jsonc when the file contains high-confidence secret-shaped text.

Wave 5

  • Threat model and residual-risks updated to match the code (including fingerprint confirmation-oracle, persisted HTTP token, and Darwin argv residual).

CI follow-ups on this branch

  • Host-matrix live MCP/CLI/OpenAPI checks skip when dist/ is missing so pnpm test:portability (no package build) still runs static host contracts. OpenAPI coverage without a build is a source assertion that the generator walks SEP_TOOL_NAMES.
  • HTTP token reuse tests set USERPROFILE as well as HOME so Windows os.homedir() sees the fixture.

Intentionally not changed

Hook fail-open default, CLI --yes / ENVSEAL_ASSUME_YES for humans, fingerprint width, MCP stdio auth, Cursor/Aider/Continue runtime hooks.

Open in Web Open in Cursor 

cursoragent and others added 5 commits August 25, 2026 10:57
Captures the 2026-08-25 review findings as sequenced work packages
with file locks, tests, and explicit non-goals so subagents can
implement without overlapping.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
Pin actions/checkout, pnpm/action-setup, and actions/setup-node to v4.4.0
commit SHAs in CI and release workflows.

Release: enforce zero lint warnings, require v* tag ref for manual publish,
and run the example-demo probe before publish preflight.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
…SSING

- Add isLinearishRegex to reject ReDoS-shaped patterns and patterns >256 chars
- Cap {m,n} quantifier upper bound at 256; reject unbounded {m,} forms
- Add SEP_PATTERN_UNSAFE and SEP_KEYS_MISSING error codes with defaults
- Regenerate manifest/tools JSON schemas with pattern maxLength

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
- Narrow code-adjacent exclusion to identifier-like tokens; do not drop
  high-entropy [A-Za-z0-9]{32,} values after JSON/JS structural punct
- Compile bounded, structurally specific registry format.pattern entries
  as high-confidence detectors; skip UUID-validation and generic shapes
- Infer prefix-synthesis body charset from registry pattern (Clerk sk_test_)
- Tighten data-URI, stack-trace path, and credentialless DB URL exclusions
- Add regression tests for JSON values, Discord pattern-only keys, and metrics

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
Close T2 bypasses: source/. file-readers, unwrap env -i/-u, busybox
wrappers, and fail-closed when shell nesting exceeds MAX_PAYLOAD_DEPTH.
Keep internal-error fail-open as the documented default.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
@cursor cursor Bot changed the title docs: security hardening plan for Composer 2.5 execution fix: security hardening from 2026-08-25 review Aug 25, 2026
cursoragent and others added 8 commits August 25, 2026 11:11
- Add ProviderKeySchema superRefine mirroring ManifestEntry: verify.url
  must be https:// and must not contain {{value}}
- Bound all provider format.pattern quantifiers from {n,} to {n,256} so
  init-to-manifest copies pass protocol isLinearishRegex checks
- Add safety tests for bounded patterns and http:// rejection at parse time

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
Implement H4–H12 for broker, sinks, manifest, and git safety:

- H6: compileSafePattern wraps all broker RegExp compilation with
  isLinearishRegex and throws SEP_PATTERN_UNSAFE
- H12: Broker.use fails before spawn on undeclared or missing keys
  (SEP_NOT_DECLARED / SEP_KEYS_MISSING); never injects a subset
- H9: add onRevokeConfirm hook; revoke fails closed without approval
- H4: Darwin keychain write passes secret on stdin via buildDarwinWriteArgs
- H11: chmod 0o600 on .env after atomic rename on POSIX
- H10: assertGitSafe requires .gitignore coverage outside git repos;
  export inspectDotenvGitSafety for Wave 3 doctor
- H5: scanText on raw manifest file text rejects secret-shaped comments

Add tests for every behaviour change; fix fixtures to use bounded
{20,256} quantifiers.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
Add revokeConfirmationBody in core and createRevokeConfirm twins that reuse
the shared ask() mutex and yes/y gate. Wire onRevokeConfirm in mcp-server
bin.ts and sdk createBroker; export createRevokeConfirm from the SDK for HTTP.

Escape probe headline key names with escapeForDisplay (S6). Update env_revoke
tool descriptions and regenerated dialect JSON. Add env-revoke e2e tests,
confirm unit tests, and sdk dispatch revoke coverage.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
…il-open

- revoke: add TTY confirmation mirroring run (--yes, ENVSEAL_ASSUME_YES)
- createBroker: pass through onRevokeConfirm to Broker
- doctor: use inspectDotenvGitSafety for gitignore.covers and isTracked
- doctor: report hookFailClosed from ENVSEAL_HOOK_FAIL_CLOSED
- exit-codes: map SEP_PATTERN_UNSAFE and SEP_KEYS_MISSING
- tests: revoke --yes/assume-yes, doctor ignore semantics, hook flag

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
- Add onRevokeConfirm via createRevokeConfirm(surface) on the Broker
- Default to ephemeral 128-bit listen tokens when no opts.token, no existing
  ~/.envseal/api-token, and ENVSEAL_PERSIST_HTTP_TOKEN is unset
- Keep persisted getOrCreateToken behaviour when persist is requested or file exists
- Extend hermeticPrompter to approve APPROVE_REVOKE for leak suite
- Add contract tests for ephemeral and existing-token modes

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
…aped comments

Wave 4 Agent J (H5): scan on-disk manifest text with @envseal/detector
before allowing FILE_TOOLS access. High-confidence hits deny with a fixed
reason that omits matched secret text. Clean or missing files still allow.
Grep skipped — not in PreToolUse hook matcher.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
Align threat-model.md with Waves 1–4 behaviour: expanded PreToolUse heuristics
(T2), raw JSONC manifest scanning and env.schema.jsonc Read deny (T3), detector
recall improvements (T4), gitignore outside git and chmod 0600 (T7), env_use
no partial inject and env_revoke confirmation (T5/T11).

Add residual risks for the 32-bit fingerprint confirmation oracle and persisted
HTTP API token; note macOS keychain stdin transport. README: Cursor/Aider/Continue
Tier B sentence, tool contract updates, nine residual risks.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
Keep the Claude Code generated provider stub aligned with bounded
format.pattern values, and satisfy lint --max-warnings 0.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
@NDilanka
NDilanka marked this pull request as ready for review August 25, 2026 11:27
Copilot AI lite review requested due to automatic review settings August 25, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

cursoragent and others added 3 commits August 25, 2026 12:06
Adds a host-matrix that checks project-marker detection, plugin MCP/CLI
snippets, a live envseal-mcp tools/list handshake (including the Claude
Code bundled CJS), SDK dialects, and HTTP OpenAPI. Cursor rules now name
all seven tools including env_await.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
security(1) ignores stdin and stores an empty password when -w is omitted.
HTTP token tests now set USERPROFILE as well as HOME so Windows os.homedir()
hits the fixture. Host-matrix live MCP/CLI checks skip when dist is absent
so the no-build portability job still runs static host contracts.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
Portability CI does not build packages. generateOpenAPI() pulls
@envseal/protocol's published entry, which is dist-only, so assert the
generator source instead and keep the live spec check for built trees.

Co-authored-by: TheCoderBTW <NDilanka@users.noreply.github.com>
@NDilanka
NDilanka merged commit fa80cff into main Aug 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants