설계: docs/superpowers/specs/2026-09-25-capability-module-packaging-design.md
계획/진행 기록: docs/superpowers/plans/2026-09-25-capability-module-packaging.md
- Wave 0: 규칙 고정(AGENTS.md capability 완료 기준·테스트 규칙) + 차단 결함 7건
(compose overlay 검사, redis-sdk CI job, 적용된 V9/V13 원복 + V16, @EnableScheduling,
messaging bridge 순서, prod 에러 상세 validator, sample loggers read-only)
- Wave 1: 데이터·보안 Critical 10건 (durable operation 25P02, operation 유스케이스 이동,
outbox 재인코딩, Kafka TLS/SASL, 알림 트랜잭션, SNS 서명, tus checksum, GraphQL fragment,
Redis lane, gRPC FAILED_TERMINAL)
- Wave 2: 리팩터링 잔재·실험용 자리 삭제, outbox v1 fencing(V17), 멱등성 V2 정본화
- Wave 3: 라이브러리형 코드 정리(동작하지 않는 설정·인터페이스·gate 제거, web-advanced 분리)
- Wave 4: capability 11개를 "있으면 켜짐" 모듈로 포장, 끄는 장치 제거, 기본 조립 web-only,
qualificationBootJar 분리
- Wave 5: 빌드 로직 축소(17.2k -> 10.8k줄), sample 테스트 컨벤션 적용
삭제한 코드는 docs/capability-status.md "제거된 코드" 표에 복구 커밋(208077fd)과 함께 기록.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
65 lines
2.7 KiB
Markdown
65 lines
2.7 KiB
Markdown
# Security
|
|
|
|
Design §36. Credential separation, privilege verification, and what never leaves the process.
|
|
|
|
## Three credentials
|
|
|
|
| Role | May |
|
|
|---|---|
|
|
| `app_migration` | own the schema, apply migrations (DDL) |
|
|
| `app_runtime` | select, insert, update, delete (DML only) |
|
|
| `app_admin` | J4 operations — COPY, backfill, maintenance |
|
|
|
|
The separation is what makes "Flyway owns schema change" enforceable rather than aspirational. If
|
|
the application's own credential cannot execute DDL, then no code path, no library, and no injected
|
|
statement can alter the schema at runtime, regardless of what the application intended.
|
|
|
|
`infra/jpa/roles/runtime-roles.sql` provisions them.
|
|
|
|
## Startup verification
|
|
|
|
`PostgreSqlRuntimeRoleVerifier` asks the *server* what the connection can do:
|
|
|
|
```sql
|
|
select current_user,
|
|
current_setting('search_path'),
|
|
has_schema_privilege(current_user, current_schema(), 'CREATE'),
|
|
has_database_privilege(current_user, current_database(), 'CREATE')
|
|
```
|
|
|
|
Configuration cannot answer this. Effective privileges come from direct grants, inherited role
|
|
memberships, `PUBLIC` grants, and schema ownership, and no reading of a deployment manifest
|
|
reconstructs that combination reliably.
|
|
|
|
Startup fails when the runtime role is not on the allowlist, or holds `CREATE` on the schema or the
|
|
database.
|
|
|
|
## search_path
|
|
|
|
`SearchPathPolicy` is an allowlist. `search_path` decides which schema an unqualified name resolves
|
|
to, so a writable untrusted schema on it — classically `public`, where `CREATE` was granted broadly
|
|
before PostgreSQL 15 — lets a planted table, function, or operator shadow the real one, and the
|
|
application executes it without noticing. `$user` is exempt: only the connected role owns it.
|
|
|
|
Refusing the runtime role `CREATE` closes the same route from the other side.
|
|
|
|
## What never leaves the process
|
|
|
|
- SQL parameter values, entity ids, tenant ids, and PII: not in exception messages, not in metric
|
|
tags, not in logs. `JpaFailureContext` composes messages from bounded values only.
|
|
- Constraint names reach the application as registered `ConstraintCode`s; an unregistered physical
|
|
name maps to a bounded unknown code rather than being passed through.
|
|
- Cursors are HMAC-signed. An unsigned cursor is client-controlled ordering state.
|
|
- The actuator report carries no JDBC URL, username, or SQL.
|
|
|
|
## Injection surfaces, and how each is closed
|
|
|
|
| Surface | Why it cannot be a parameter | Closed by |
|
|
|---|---|---|
|
|
| sort field | part of ORDER BY | `SafeSortRegistry` allowlist |
|
|
| JSON path | part of the statement | registered `JsonPathName` |
|
|
| schema name | an identifier | registered `SchemaTenantRegistry` |
|
|
| COPY table | an identifier | registered `RegisteredCopyStatement` |
|
|
|
|
Values are always bound. Identifiers are always registered.
|