Threat Model
STRIDE applied to the trust boundaries enumerated in trust boundaries. Priority threats are listed first; the full STRIDE matrix follows.
Priority threats
Section titled “Priority threats”T1. Prompt injection via retrieved chunks (indirect)
Section titled “T1. Prompt injection via retrieved chunks (indirect)”- Boundary: the prompt-construction edge inside the API Lambda where third-party-origin chunks meet the prompt template (the in-process boundary; not a network hop).
- Mechanism: the corpus is
neural-bridge/rag-dataset-12000, Apache-2.0, authored by a third party. Any chunk can contain text shaped as instructions to the LLM (“ignore previous instructions and…”). When retrieval places that chunk into the system prompt verbatim, the model may follow those instructions. - Impact: answers diverge from grounded content; the model may reveal the system prompt, produce off-policy content, or emit attacker-chosen text the user attributes to the product.
- Likelihood today: low (curated public Q&A dataset), but the architecture cannot distinguish a friendly corpus from a hostile one. Likelihood becomes high the day the corpus is swapped.
- Mitigations:
- Today: clearly delimit retrieved content in the prompt (e.g. fenced blocks); add an explicit instruction that any imperative text inside the delimiters is data, not instructions; log prompt + response for review.
- Capability #44 / Decision #55 (closed): Safety Gate via Bedrock Guardrails evaluates the generated answer before return.
- Defense in depth: never echo retrieved content into a tool-use or function-call argument (we currently call neither — guardrail for the future).
T2. Direct prompt injection via /query body
Section titled “T2. Direct prompt injection via /query body”- Boundary: Browser → CloudFront → API Gateway → Lambda (the user-supplied
questionfield). - Mechanism: the user submits a
questionthat contains adversarial prompt content. Without input shaping, the model receives ”${SYSTEM}\n${QUESTION}” with the user’s text potentially containing role markers, jailbreak templates, or instructions to leak the system prompt. - Impact: same class as T1, but originated by the requester. Lower stakes since the requester is also the audience, but matters if the answer is shared, screenshotted, or logged.
- Mitigations:
- Cap question length (HTTP 422 on oversized is in retrieval spec; confirm the cap is e.g. 2KB, not arbitrary).
- Strip or escape control characters; never interpolate the question into the system prompt block.
- Rely on the same Safety Gate path as T1 for output-side mitigation.
T3. PII / sensitive-data exfiltration if the corpus is ever swapped
Section titled “T3. PII / sensitive-data exfiltration if the corpus is ever swapped”- Boundary: ingestion → Aurora; ingestion → Bedrock embeddings.
- Mechanism: the architecture treats the corpus as one data class (data classification). If a future operator points ingestion at a corpus containing PII, secrets, or internal documents, the existing pipeline embeds that content via Bedrock and stores it in pgvector. The
/queryendpoint is then an exfiltration interface for whatever is in the table, gated only by operator-issued bearer tokens, one per recipient (RAG009), each with a lifetime request quota and an expiry (plus the keys QA CI jobs mint for a single run and delete at its end, RAG009 amendment; each expires one day after issue). Prospective employers each get their own key, labeled with the company, so a leaked key is traced to one recipient and revoked alone. - Impact: depending on the swapped corpus, ranges from embarrassing to a notifiable breach.
- Mitigations:
- Today: the data-classification rule (one class today; reclassification triggers a re-review) is the gate. No automated control prevents an operator from pointing the pipeline elsewhere.
- Before any reclassification: output filtering, retention/deletion policy, a key-management review beyond capped per-recipient keys, and a compliance scope reassessment (compliance).
T4. Cross-environment reach of the CI deploy roles
Section titled “T4. Cross-environment reach of the CI deploy roles”- Boundary: CI → AWS (GitHub Actions OIDC → the QA and Prod Terraform deploy roles).
- Mechanism: a workflow that passes only the
qaGitHub environment gate assumes the QA deploy role, creates a Lambda role under the stack-role boundary, whose DB-secret grant covers everyrds!*secret in the region, and reads Prod’s DB secret through it. The same role holds other grants that cover Prod’s resources too, listed as residuals under Mitigations. The Prod deploy role has the same reach into QA. Each deploy role’s state, bucket, Lambda function, CloudFront distribution and function, and database grants are environment-scoped (deployment plan, Secrets and IAM Strategy). - Impact: the QA gate becomes a path to the Prod DB master secret value and Prod KMS keys, and through the other residuals lets a QA job change or delete Prod resources such as its API routes, network, log groups, alarms and certificate, breaking the QA/Prod separation in RAG001.
- Status: partly mitigated; open risk #504 for the boundary and KMS residuals. The other residuals under Mitigations have no risk issue.
- Mitigations:
- Each role’s OIDC trust policy exact-matches
repo:ArunskiOrg/rag-sample-app:environment:<env>, so only a job in that repo declaring the environment can assume it. - Each role’s
rds:*, Data API and Secrets Manager read grants cover only its own environment’s resources, and aterraform testfails if that changes. - Each role reads and writes only its own environment’s Terraform state and Lambda package objects (its
rag-sample/<env>/key prefix), its ownrag-sample-<env>-*buckets and Lambda functions, the CloudFront distributions tagged with its environment andProject = rag-sample, and itsrag-sample-<env>-*CloudFront functions. A role can neither tag its own distribution into the other environment nor remove itsEnvironmentorProjecttag.make deploy-role-simulate ENV=<env>checks the policy logic with the IAM policy simulator: 12 probes against the role’s own environment, expected allowed, and the same 12 against the other environment, expected denied (state object, package object, frontend bucket, frontend object, distribution create by request tag, distribution update, invalidation and tag, CloudFront function, Lambda code update,rdscluster,rds-datacluster). It also probes the own DB secret (the make target passes the environment root’sdb_secret_arnoutput; a direct script call probes it only with--secret-arn), the other environment’s secret through a placeholder ARN, and the role’s own distribution retagged into the other environment, expected denied. A missing context key fails a probe, except keys the probe leaves unset on purpose forNullandIfExistsconditions. The probes supply the tag values as request context, so the check does not confirm that deployed distributions carry the tags. It probes only the state, package and frontend bucket, CloudFront distribution and function, Lambda,rds,rds-dataand DB secret grants, so it probes none of the residuals below, and it does not probeUntagResource: theterraform testsuite alone checks that a role cannot remove theEnvironmentorProjecttag. - The
terraform testsuite ininfra/modules/cicd/tests/cicd.tftest.hclruns in theterraform.ymlCI workflow and fails if the storage, Lambda and CloudFront scoping changes: object access underrag-sample/<env>/in both shared buckets, of the two shared bucketss3:ListBucketon the state bucket only, bucket management onrag-sample-<env>-*,lambda:*onrag-sample-<env>-*functions and no Lambda action onResource "*", nocloudfront:*, both tags on every Allow on distribution ARNs, this environment’s request tags on distribution tagging,UntagResourceonly for keys other thanEnvironmentandProject, therag-sample-<env>-*function prefix, and CloudFront actions onResource "*"limited to the creates, theTagResourcein the create statement, and managed-policy lookups. The simulator runs against the deployed role and is not part of CI. - Residual: CloudFront origin access controls and response headers policies have generated ids and accept no tag condition, so either role can read, change or delete the other environment’s. Neither holds data or credentials.
- Residual: any distribution in the account with no
Environmenttag and noProjecttag other thanrag-sample, another stack’s included, can be tagged into either environment by that environment’s deploy role, which then can update or delete it. Whether every distribution in the account carries aProjecttag is unverified. - Residual:
s3:ListBucketon the whole state bucket lets each role list the other environment’s state key names; object reads stay limited to its own prefix. - Residual:
RegionalStackServices(ec2,kms,apigateway,logs,cloudwatchandxrayon all resources in the region) is not environment-scoped. API Gateway ids are generated, so no name prefix can scopeapigateway:*, and either role can change the other environment’s API routes or integrations, change or delete its VPC network resources, delete its log groups, or delete or disable its alarms. - Residual:
AcmStackCertificateskeys only on theProject = rag-sampletag, which both environments’ certificates carry, so either role can describe, retag, change the options of, or delete the other environment’s certificate (ACM refuses the delete while CloudFront uses the certificate). - Residual:
BedrockGuardrailManagecoversguardrail/*in the account and region for both environments, so either role can change or delete the other environment’s guardrail. - Residual: a deploy role can still create and tag RDS-managed secrets (
rds!cluster-*) in the region, since RDS names them after the cluster exists, and readrds:Describe*metadata for both environments. Neither exposes a secret value or data. The boundary’s DB-secret grant (secretsmanager:GetSecretValueon everyrds!*secret in the region) still lets a deploy role read the other environment’s DB secret value through a Lambda role it creates under the boundary; Data API access through that role stays limited to its own cluster. The KMS grant (kms:*on every key in the region) is not environment-scoped.
- Each role’s OIDC trust policy exact-matches
Full STRIDE matrix
Section titled “Full STRIDE matrix”S = Spoofing, T = Tampering, R = Repudiation, I = Information disclosure, D = Denial of service, E = Elevation of privilege.
| Boundary / asset | S | T | R | I | D | E | Notes |
|---|---|---|---|---|---|---|---|
| Browser → CloudFront → API Gateway | M | L | L | L | M | L | Browser → CloudFront and CloudFront → API Gateway are separate TLS connections, terminating at CloudFront and API Gateway respectively. The API Gateway default endpoint is also reachable directly, bypassing CloudFront, so authentication and throttling sit at API Gateway. POST /query requires a bearer token validated by the Authorizer Lambda (RAG009), so spoofing means presenting a key issued to someone else; the per-key lifetime request quota limits that risk. /healthz and /readyz are unauthenticated by design; /readyz runs one SELECT 1, so a caller can keep Aurora from pausing at up to its 1 req/s throttle, an ACU cost exposure rather than a data exposure. Only the routes the app serves exist, so path variants of /query either get the gateway’s 404 or match the authorized route, and never reach FastAPI without the authorizer (#380). DoS mitigated by API Gateway throttles on every route: POST /query under Story #65, GET /healthz and the stage default under #380, GET /readyz under #389 (see assessment, Controls in place). |
| API Gateway → Lambda | L | L | L | L | L | L | AWS-managed integration; SigV4 not user-controllable. |
| Lambda → RDS Data API | L | L | L | L | L | L | IAM-authed HTTPS; least-privilege role; statements parameterized. |
| Lambda → Bedrock | L | M | L | M | M | L | Tampering and disclosure manifest as T1/T2 above. DoS is the cost-runaway shape, bounded by the per-key quota and route throttle and detected by the daily Bedrock budget (spend and abuse runbook). |
| Prompt construction (in-Lambda) | n/a | H | L | M | L | L | T1 lives here. The “tampering” is corpus-origin instructions altering model behavior. |
| Lambda → Secrets Manager | L | L | L | L | L | L | IAM-scoped to one secret ARN; credentials never leave Lambda memory. |
| Aurora at rest | L | L | L | L | L | L | KMS-encrypted; no public endpoint; security group denies inbound except Data API service. |
| Ingestion → Hugging Face | M | M | L | L | L | L | Upstream integrity is implicit trust today. Pin dataset revision SHA if ingestion ever becomes unattended (gap in assessment). |
| Ingestion → Aurora | L | L | L | L | L | L | Same control surface as the API Lambda path. |
| CloudFront / S3 SPA | L | L | L | L | L | L | Public static assets; no secrets in the bundle (VITE_API_URL is a public URL). |
| CI → AWS (Terraform apply) | M | M | M | L | L | H | GitHub Environment + manual Prod gate (RAG001) constrains who can apply; OIDC role with environment-scoped trust policy is the implementation expectation. Elevation is T4: each deploy role’s direct database grants are scoped to its environment, but the stack-role boundary and kms:* still reach the other environment (risk #504). |
Legend: L = low, M = medium, H = high. “L” everywhere is not “no risk”; it is “addressed by an explicit control or accepted explicitly”.
What is not covered
Section titled “What is not covered”- Physical security of the operator’s machine (out of scope; local dev environment).
- AWS-managed-service internals (Bedrock model weights, Aurora storage layer).
- Browser-side threats against the operator’s own session (XSS, CSRF) — the only client state is the recipient’s bearer key the user pastes in, capped by its lifetime request quota, plus the question + answer pair on the page.
A re-run of this threat model is warranted when any of these change: the key model moves beyond capped per-recipient keys, the corpus is reclassified, a Safety Gate is implemented, or Lambda moves into a VPC (RAG004 revisit).
© 2026 Benjamin Arunski