Skip to content

Security Assessment

This is a personal demo. The threat model is shaped by that: no user data, no compliance scope, a single operator, and an Apache-2.0 third-party corpus reaching the LLM prompt verbatim. The controls are sized accordingly. Production-grade items that are not warranted at this scale are listed as accepted risks rather than gaps.

  • In scope: the AWS deployment described in Infrastructure (QA + Prod, single account), the FastAPI Lambda, Aurora Serverless v2 with pgvector, AWS Bedrock (Titan embeddings + Haiku-class generation; generation runs through a cross-region inference profile that may execute the request in us-east-1, us-east-2, or us-west-2, so prompt content does not stay in the calling region — RAG007), the CloudFront/S3 SPA, the one-off ingestion Lambda, and the corpus pipeline from Hugging Face.
  • Out of scope: the local Docker dev environment (operator’s machine; not a production surface), upstream Hugging Face Hub controls, AWS managed-service internals.
ControlMechanismSource
Environment isolationSeparate VPCs per environment in one AWS accountRAG001
Production change gateGitHub Environment manual-approval rule on Prod applyRAG001
Network minimizationNo IGW, no NAT, Lambda outside VPC; Aurora reached via RDS Data API (HTTPS, IAM-authed)RAG010, RAG011
Encryption in transitHTTPS at API Gateway, CloudFront, Bedrock, RDS Data API, Secrets Manager (all AWS-managed TLS)Infrastructure
Encryption at restAurora storage encryption, S3 default encryption, Secrets Manager (AWS-managed KMS)Infrastructure
CredentialsLambdas find DB credentials in Secrets Manager, and pass secret ARN to the RDS Data API; no static secrets in code or envRAG011
Least-privilege IAMLambda execution role scoped to bedrock:Invoke*, rds-data:* on one cluster ARN, secretsmanager:GetSecretValue on one secret ARNInfrastructure
Input validationPydantic on /query; HTTP 422 on empty/oversized questionspecs/retrieval
Output groundingSystem prompt instructs Claude to answer only from provided chunks and cite by indexspecs/retrieval
Supply chain (Python)Pinned lower bounds in pyproject.toml; ingestion tree minimized to huggingface-hub + pyarrowRAG002, RAG003
Test floor90% aggregate / 70% per-file coverage hard-fail in CIRAG006
API contract controlopenapi.yaml committed, CI diff-checked, CODEOWNERS on spec and routesRAG005
ObservabilityStructured logs with explicit, finite retention: 30 days on the authorizer log group, 14 days on the API and access log groups; per-environment CloudWatch alarms emailing the operator through one account-level SNS topic; X-Ray tracing on both Lambdas until #416 removes it. Target per RAG020: P-2.4 (#416) adds EMF metrics, removes tracing, and sets every log group to 30 days (D-8) from one variable per environment.RAG020
Route-level rate limitPOST /query has an API Gateway route-level throttle at 1 req/s steady-state, burst 5, as defense-in-depth behind RAG009’s per-key lifetime request quota; GET /healthz is throttled at 3/6, GET /readyz at 1/3 and the stage default at 1/2. /healthz and /readyz are unauthenticated; /readyz runs one SELECT 1, so any caller can wake Aurora or keep it from pausing, at most one request per second, the same keep-awake exposure a well-formed fake bearer on POST /query already has. Only the routes the app serves exist, so any other path either gets the gateway’s 404 or matches an existing route and its authorization, and never reaches the API Lambda unauthenticated. The authorizer’s reserved concurrency of 5 caps concurrent key-quota decrements; callers beyond that get a 500 (a flood, or slow Data API calls such as an Aurora resume), visible in the stage 5xx metric and the access log’s authorizerError field. In Lambda the app also turns off /docs, /redoc and /openapi.json (#380)Story #65 (closed as completed), Network Topology
Cost guardrailsA blocking Infracost check on every Terraform PR that fails when an environment’s fixed-price monthly total exceeds its ceiling, plus a cost diff comment. Both cover Terraform-managed infrastructure only: Infracost prices a plan, so usage-driven Bedrock spend (the largest line item at volume) is invisible to it. Usage spend is covered by two AWS Budgets created in bootstrap, rag-sample-bedrock-daily ($5/day, filtered on the Bedrock services) and rag-sample-monthly ($40, account-wide), and four CloudWatch alarms per deployed environment, all emailing the operator through the rag-sample-alerts topic (#385, spend and abuse runbook). The preventive caps are RAG009’s per-key lifetime request quota and the POST /query route throttle (1 req/s, burst 5) (risks.md R2).RAG021, Environments & CI
RiskWhy accepted
Shared AWS account boundary between QA and ProdRAG001 weighs this against Organizations overhead; isolation at VPC + IAM is adequate for a demo. Migration path documented.
Third-party corpus content reaches the LLM prompt verbatimApache-2.0 public dataset; we trust the upstream maintainer no more than necessary. Prompt-injection is the threat-model consequence, not a code defect — see threat model.
No Safety Gate on responses todayModeled as future component (Capability #44); Bedrock Guardrails approved per Decision #55 (closed), gated on #44 entering Stage 3.
Self-review on OpenAPI changesRAG005 acknowledges single-operator consumer rep; process exists for when roles diverge.
Prompt content leaves the calling region via Bedrock cross-region inferenceGeneration runs through a us. inference profile, so the request may execute in any region of that profile’s group (RAG007 requires the IAM grant to name every region the profile can route to; the region list itself lives in the API module’s Terraform). Demo scale, no personal or sensitive data expected in the question, and the AWS trust boundary is unchanged — the region of execution moves, the call stays inside AWS under the same IAM grant. See trust boundaries B5.
Lambda reaches AWS services over the public internet (RDS Data API, Bedrock, Secrets Manager)RAG001: PrivateLink/NAT cost is disproportionate at demo scale. All calls are TLS + SigV4.

Items previously listed as accepted risks or open gaps that have since been superseded by an explicit decision. Kept here for audit history.

RiskResolved by
/query is unauthenticated and publicPreviously listed under Accepted risks. Superseded by RAG009: bearer-token Lambda authorizer backed by an Aurora api_keys table, with a per-key lifetime request quota. Realized by Feature #59 (Stories #60 authorizer, #61 key issuance, #62 log scrub, #63 SPA key intake, all closed). The authorizer is deployed and POST /query returns 401 without a bearer token; /healthz remains unauthenticated by design. See per-feature security requirements.
No rate limit on /queryPreviously listed under Gaps. Resolved by Story #65 (closed as completed): API Gateway route-level throttle on POST /query at 1 req/s steady-state, burst 5, behind RAG009’s per-key lifetime request quota. Since #380, GET /healthz has its own throttle (3/6), and GET /readyz (#389) has 1/3. See Controls in place.
No abuse alarm on Bedrock token spendPreviously listed under Gaps. Resolved by #385, which supersedes Story #64: the rag-sample-bedrock-daily ($5/day) and rag-sample-monthly ($40) budgets plus per-environment CloudWatch alarms publish to rag-sample-alerts. See Controls in place and the spend and abuse runbook.
Trust-boundary documentation has no home in LikeC4Previously listed under Gaps. Resolved by Decision #51 (closed): #trustBoundary tag added to the LikeC4 specification and applied to container relationships in architecture/_systems.c4; narrative lives at trust boundaries.

These are the items the architect-reviewer should weigh at the Prod promotion step. They are not blockers for the Prod deploy; they are blockers for treating Prod as more than a demo.

GapRecommendationOwner
Prompt-injection mitigations not implementedTreat retrieved chunks as untrusted: delimit clearly in the prompt, instruct the model to ignore embedded instructions, log responses for review. Full Safety Gate is Capability #44 / Decision #55 (closed).Architect, Operator
Direct prompt-injection via /query bodyCap question length (already 422 on oversized — confirm bound is meaningful, e.g. 2KB), strip control characters, never echo question into system prompt.Operator
Corpus integrity is implicit trust in Hugging FaceOne-off ingestion is acceptable today. If ingestion ever becomes scheduled or unattended, pin dataset revision SHA and record it in run metadata.Operator
/healthz polled every 30s from every SPA tab/healthz is unauthenticated by design under RAG009 (no bearer required). Confirm it does not exercise Bedrock. It has its own route throttle (3/6), separate from the POST /query throttle (see Controls in place).Operator
Dependency vulnerability scanning not in CIAdd pip-audit (or equivalent) as a non-blocking PR check; promote to blocking once noise level is known.Operator
No documented incident response runbookOne-page runbook: revoke Lambda IAM role, rotate DB secret, disable API Gateway stage, expected dwell time. Demo-scale but worth having before public link.Operator

The architect-reviewer closes the Stage 3 gate against this assessment plus the companion documents in this section. The Prod manual-approval step (RAG001) is the operational checkpoint where the gaps above are re-checked at every release.