Security
How detection and access work in production, what Task 3 built, and what is not built.
Security monitoring has two halves. Detection watches the account and the edge for attacks and misuse. Access control limits who and what can touch data and telemetry. Task 1 built most of the access side. Task 3 adds telemetry that is safe to collect, and narrows CORS. The detection services are not built.
In production
- Detection. GuardDuty on the account, VPC flow logs (built in Task 1) and CloudTrail. Findings go to Security Hub, and high-severity findings to the same SNS topic and PagerDuty as the service alarms. WAF managed rules and the rate limit block at the edge (built in Task 1); WAF logs record what they blocked.
- Access. People get short-lived roles through IAM Identity Center, one account per environment. Workloads get task roles with only the actions they need. Telemetry is written by the collector’s narrow permissions and read through CloudWatch, never through the application.
- Data. Document text stays in the database. Telemetry carries IDs, sizes, counts, timings and exception types.
Controls
| Control | Built | File | Not built |
|---|---|---|---|
| Telemetry carries no document text, model output or exception message | Yes, enforced by tests | server/app/telemetry.py, server/tests/test_telemetry.py |
Scrubbing covers exported spans and uvicorn.error; a traceback from another logger is not rewritten |
| CORS | Allowed origins come from CORS_ALLOWED_ORIGINS, and the default is none. Previously it was * with credentials. The client is same-origin: CloudFront in AWS, the Vite proxy locally. |
server/app/__main__.py |
|
| Collector permissions | The task role can do logs:CreateLogStream and logs:PutLogEvents on the metrics log group only, and xray:PutTraceSegments in this region. PutTraceSegments has no resource-level scoping, so its resource is *. |
infrastructure/modules/service/iam.tf |
Not checked against a live account |
| Collector exposure | The OTLP receiver listens on 127.0.0.1:4318 inside the task only |
observability/collector/aws.yaml |
|
| Collector container | Runs as non-root (uid 4317) with a read-only root file system; image pinned by digest | infrastructure/modules/service/ecs.tf, main.tf |
Pulled from public ECR through the NAT; no private mirror |
| Log encryption and retention | Customer-managed KMS key; 30 / 90 / 365 days | infrastructure/modules/service/ecs.tf |
|
| Application audit events | Document read and save | server/app/telemetry.py |
No actor; the address is the ALB’s (details) |
| Account trail | CloudTrail organisation trail, AWS Config, Security Hub | ||
| Threat detection | VPC flow logs (Task 1) | infrastructure/modules/network |
GuardDuty; WAF, ALB and CloudFront access logs |
| Secrets | The OpenAI key is in Secrets Manager (Task 1). The Datadog option reads DD_API_KEY from the environment. |
infrastructure/modules/data, observability/collector/datadog.yaml |
The Datadog key’s secret is not created, because that config is not deployed |
| Local stack | Grafana allows anonymous viewers with no login form, for a laptop only | observability/docker-compose.yml |
Telemetry as a data store
Telemetry is a copy of production behaviour, so it is treated like one. The rule is no content in telemetry, enforced in code and tests. That keeps the log groups, X-Ray and any third-party back end out of the scope of document confidentiality, though not out of access control. With Datadog, the same rule is what makes sending telemetry to a third party acceptable.