Skip to content

Security: thisisouvik/ImpactRelay

Security

docs/security.md

Security, privacy, and agent safety

Security posture

ImpactRelay currently handles two sensitive capabilities:

  1. It receives user-provided case information.
  2. It can call external tools based on model output.

The Stellar/x402 payment boundary is documented as future work and is intentionally not executable in the current runtime. There is no signer, facilitator integration, payment receipt, or real payment approval flow yet.

The MVP is a research/demo system. It must be honest about that boundary and default to the least powerful behavior that still demonstrates the product.

The current browser workflow uses an HttpOnly anonymous session cookie and stores only its hash with each case. This prevents a bare case UUID from reading, exporting, planning, running, or pausing another browser session's case. It is not a substitute for authenticated users, account recovery, team access control, or server-side authorization policies.

Threat model

Threat Example Primary control
Secret exposure Provider key or Stellar secret enters browser/logs Server-only modules, redaction, bundle review
Prompt injection A fetched page tells the agent to ignore policy Treat tool output as untrusted data
Excessive spending Model requests many paid calls Allow-list, per-call cap, run cap, approval
Payment replay Same signed payment buys multiple responses Intent IDs, idempotency, facilitator verification
Fake settlement Client claims a payment succeeded Server-side verification and settlement status
Data leakage Sensitive case text is sent to unnecessary tools Data minimization and tool-specific input mapping
Hallucinated evidence Model cites a source it did not read Evidence created only from adapter results
Stale information Weather or shelter data is old Retrieval time, freshness, human verification
Tool compromise Paid service returns malicious content Schema validation, size limits, output isolation
Testnet confusion User mistakes fake assets for real money Persistent Testnet labels and no Mainnet path

Secret rules

  • Provider API keys are server-only.
  • Stellar private keys are server-only and disposable in Testnet mode.
  • x402 payment signatures and raw authorization payloads are sensitive; do not log or persist them unless the integration explicitly requires short-lived storage.
  • Environment variables must be validated at the server boundary.
  • Client components must not import payment or provider modules.
  • Never include real keys in examples, fixtures, screenshots, or documentation.

Payment safety policy

The policy engine—not the LLM and not the browser—must enforce:

network == stellar:testnet
asset is allow-listed
tool is allow-listed
amount <= maxAmountPerPayment
totalReserved + amount <= maxAmountPerCase
quote has not expired
step has not been settled already
approval exists when required

Recommended initial limits:

maxAmountPerPayment = $0.02
maxAmountPerCase = $0.05
maxPaidStepsPerCase = 3

These are product defaults, not security guarantees. Store amounts as decimal-safe strings or atomic units.

Approval levels

Level Behavior
none Free read-only tool under the allow-list
policy Paid call automatically allowed below a tiny configured threshold
human User must approve this payment in the UI
blocked Tool, asset, network, or amount is not permitted

The MVP should use human for the first real payment so the demo makes the boundary visible.

Prompt-injection defense

External text is data, not instructions. The agent runtime must:

  • Wrap fetched content in a clearly labeled untrusted-data section.
  • Never add external text to system-level policy instructions.
  • Keep tool selection and payment policy outside the model prompt.
  • Validate tool arguments with schemas.
  • Limit output length and nesting.
  • Ignore requests from a source to reveal secrets, change policy, or perform unrelated actions.
  • Record a warning when untrusted text contains instruction-like content.

The model should receive only the minimum content needed for the current step.

Privacy rules

  • Tell users not to enter real sensitive personal data in the hackathon demo.
  • Do not collect names, exact addresses, health information, identity documents, or financial data unless a future documented feature requires it.
  • Redact or hash sensitive values in logs.
  • Store the minimum case text needed to reproduce the demo.
  • Make export explicit and user initiated.
  • Define a retention period before introducing hosted persistence.
  • Never send case data to a paid tool unless the tool contract and user flow justify it.

Evidence integrity

The application must distinguish:

  • source-fact: directly returned by a tool or user.
  • model-synthesis: generated by the LLM from recorded evidence.
  • recommendation: a proposed next step, not a verified fact.
  • human-confirmed: explicitly confirmed in the UI.

Only an adapter may create a source-backed evidence item. The model may summarize evidence but may not fabricate source URLs or transaction IDs.

Error behavior

Security failures should fail closed:

  • Missing signer → no payment.
  • Unknown network → no payment.
  • Invalid quote → no payment.
  • Invalid output schema → no evidence promotion.
  • Unverified settlement → no paid content unlock.
  • Budget exceeded → case pauses for review.

The user-facing error should explain the safe next action without disclosing internal secrets or sensitive provider details.

Logging and monitoring

Allowed event metadata:

  • Case ID.
  • Step ID.
  • Tool ID.
  • Provider ID.
  • Status.
  • Duration.
  • Amount and network, if a payment was proposed or settled.
  • Redacted error code.

Disallowed by default:

  • Private keys.
  • Authorization headers.
  • Payment signatures.
  • Full raw prompts.
  • Full personal data.
  • Unredacted external documents.

Security review before real testnet use

  • Confirm no secret is imported by a client component.
  • Inspect the production bundle for key names and private-key patterns.
  • Test over-budget, rejected, duplicate, expired, and failed payments.
  • Confirm payment status comes from the server/facilitator.
  • Confirm Mainnet is not selectable in MVP configuration.
  • Use a fresh disposable wallet.
  • Review logs during one complete testnet run.

Future hardening

Before any real-money or multi-user deployment, add:

  • Authenticated users and case ownership.
  • Server-side rate limits.
  • Stronger database access controls.
  • Key management or a wallet service designed for custody boundaries.
  • Formal privacy/retention policy.
  • Independent review of x402 integration and payment replay protection.
  • Abuse monitoring and incident response.

There aren't any published security advisories