---
name: security-preflight
description: Review a design or implementation for exploitable trust-boundary failures using code-grounded abuse cases and targeted tests. Use for security reviews and changes to authentication, authorization, agent authority, untrusted input, secrets, or deployment exposure; not as permission to scan or attack external systems.
---

# Security Preflight

How could someone make this do something they are not entitled to do?

Start with the user's intended capability and the current implementation.
Protect that capability, not an imaginary read-only replacement. A useful
review identifies concrete attack paths, closes them at the right boundary,
and proves that legitimate work still succeeds.

## Define the review and its authority

Identify the proposed change, exposed entry points, assets worth protecting,
and actors with different levels of access. Include ordinary authenticated
users, untrusted documents or websites, extensions, and external services when
they can influence the affected behavior.

Read relevant repository instructions, code, configuration, and tests. Trace
actual enforcement rather than trusting a design description or scanner label.
Distinguish facts, assumptions, and unanswered questions.

Keep testing within the user's authorization. Prefer local fixtures and
disposable environments. Do not probe third-party services, enumerate real
accounts, access other people's data, exploit production, or publish a finding
without the corresponding explicit scope. Stop a proof once its consequence
is established; do not extract additional data to make it look convincing.

## Turn the change into abuse cases

Follow input to interpretation, authority, effect, and output. Select the attack
paths relevant to that chain rather than reciting every vulnerability category.

- **Identity and authority.** Can a caller forge identity, substitute a resource
  ID, cross an account boundary, elevate privileges, reuse a revoked grant, or
  bypass a check through another API or tool? Interface visibility is not
  server authorization. Check state-changing browser requests and session
  boundaries for cross-site abuse where cookies carry authority.
- **Untrusted input.** Can data become executable code, a database expression,
  markup, a shell argument, a template, a filesystem path, or an agent instruction?
  Trace the actual parser and sink, including redirects and archive extraction.
  Prefer structured interfaces and context-appropriate validation or encoding.
- **Network and file access.** Can an allowed URL, upload, or path reach a more
  privileged destination? Consider internal services, metadata endpoints,
  redirect chains, DNS changes, symlinks, executable content, and resource
  exhaustion where the implementation permits them.
- **Credentials and sensitive output.** Follow secrets through storage,
  providers, logs, errors, analytics, generated artifacts, and backups. Check
  exposure, scope, expiry, revocation, and recovery. Report secret locations
  with redacted evidence, never the secret itself.
- **Cryptographic claims.** When encryption or signing is involved, trace key
  custody, verification, rotation, and failure behavior. Prefer established
  primitives and maintained libraries. Transport encryption, encrypted storage,
  and end-to-end protection are different guarantees; identify who can decrypt.
- **Concurrency and replay.** Can retries, duplicate requests, races, stale
  permissions, or partial failure repeat an effect or bypass an invariant?
  Check the transaction or idempotency boundary that owns the effect.
- **Dependencies and deployment.** Examine relevant package provenance,
  update integrity, default credentials, debug routes, administrative exposure,
  process privileges, and production configuration. A safe development setup
  is not evidence about the shipped artifact.

Describe each credible case as actor, prerequisite, entry point, missing
control, and consequence. A dependency advisory or suspicious pattern is a
lead until reachability and impact have been assessed.

## Review agent authority without disabling the agent

Separate the user's request from instructions found in a page, file, message,
tool result, or retrieved document. That content can supply evidence, but it
cannot grant itself access or expand the task. Validate resource identifiers
and enforce authorization in deterministic code, not through model promises.

Distinguish permission to start work, permission to read its inputs, permission
to take an action, and permission to disclose its results. Preserve the user's
authorized scope across delegation, retries, and delayed delivery. Signing in
grants access, not an open-ended mandate to do anything the account can do.

Do not introduce a second approval for every ordinary step already covered by
the request. A tool may read and act. Make consequential actions understandable,
and stop when an action exceeds the authorized scope or unresolved uncertainty
makes it materially destructive, irreversible, or dangerous. Inspect existing
approvals and execution receipts before asking the user to authorize the same
work again. Do not blindly replay an action whose effects are uncertain.

## Verify the control and the useful path

Build the smallest safe reproduction. Pair the exploit or denial test with a
legitimate operation using the same mechanism. Include another entry point,
role, or lifecycle state when it has materially different enforcement.

Check the shipped or deployed configuration when the finding depends on it.
Use scanners as supporting evidence, not as a substitute for tracing behavior.
If code is unavailable or the environment cannot safely reproduce a case,
name that limitation instead of inventing a successful test.

Recommend fixes at the authoritative boundary. Avoid duplicated policy engines,
blanket feature bans, arbitrary limits, and approval loops that conceal the
defect by making the product unusable. For an authorized fix, include recovery
and compatibility when old sessions, jobs, data, or clients remain in flight.

## Applying this to Nautilo

Establish the reviewed checkout and affected execution path first. These are
source-navigation and regression checks, not a claim that every deployment
has every protection. Do not infer an encryption guarantee from a package
name, successful login, or a green unit suite.

- **Application authority:** trace the authenticated principal through
  `packages/trust` into server/tool enforcement and the memory access envelope.
  Keep room admission, agent interaction, namespace read/mutation/attachment,
  and tool execution distinct. A forged room ID or prompt must not select a
  more privileged envelope. Test a legitimate shared-Genie operation alongside
  the denied cross-audience operation; do not substitute owner-only access.
- **Cryptographic authority:** inspect the binding, keyring, and recipient
  verification in `packages/lattice-crypto`, then its callers in
  `packages/lattice-bridge`. Test wrong Namespace, Domain, key class, recipient,
  revision, and authenticated head. Verify the anchored binding chain, not
  merely a valid signature on a stale or unrelated object. Historical signature
  validity and present permission to perform an operation are separate checks.
- **Grants and cached authority:** follow the protected invocation's required
  namespace set and current authorization into the effect callback. Reject
  missing, extra, or stale authority without executing the effect. Check Domain
  key caches against server, user, profile, device, key generation, and head
  requirements. Revalidation need not mean asking the human to approve again.
  Inspect cleanup on both success and exceptions so opened key material does
  not outlive its intended use.
- **Workstation boundary:** follow `README.ai` and the actual Workbench,
  Desktop preload/main, and relay call path. A renderer or browser client must
  not obtain filesystem or shell authority by bypassing the relay, sender
  checks, or tool policy. Test the legitimate Desktop path and rejection of
  a forged sender or unavailable relay where the change affects that boundary.
- **External actions:** trace the selected connection, authenticated account,
  authorized task, execution, and completion through the actual tool/runtime
  implementation. Website text cannot enlarge the task. Signing in is not a
  blanket mandate, but an authorized task can include navigation and mutations.
  Preserve that workflow; do not impose read-only Browser Use or redundant
  confirmations. Inspect uncertain effects before retrying.

Useful existing regressions include
`packages/lattice-crypto/tests/unit/namespace-v2-binding.test.ts`,
`packages/lattice-crypto/tests/unit/namespace-rebind-v2.test.ts`,
`packages/lattice-crypto/tests/unit/domain-key-authority-v2.test.ts`,
`packages/lattice-bridge/tests/unit/domain-key-cache-v2.test.ts`, and
`packages/lattice-bridge/tests/unit/protected-grant-session-authority-set-invocation.test.ts`.
Read the assertions and run the relevant tests. Mocked authorization and
synthetic storage do not prove server wiring, provider behavior, or deployed
key custody; verify those separately when the reviewed change depends on them.

## Return the review

Lead with **Ready**, **Ready with named decisions**, or **Blocked** for the
reviewed scope. Report actionable findings, not a transcript:

- Severity justified by impact, exposure, and prerequisites.
- Affected code and a concrete abuse path; label unproven hypotheses.
- The proposed fix and negative and positive regression tests.
- Verification performed, remaining uncertainty, and release-blocking decisions.

Keep sensitive reproduction details out of public issues and logs. A review
with no findings means no issues were found within the stated scope and
methods. It is not certification that the system is secure.

For deeper checks, use the current primary guidance relevant to the finding:
[OWASP Authorization](https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html)
and [OWASP Prompt Injection Prevention](https://cheatsheetseries.owasp.org/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.html).
These references support investigation; they do not grant testing authority.
