photoncloud-monorepo/docs/por/T058-s3-auth-hardening/task.yaml
centra 07b3320436 feat(lightningstor): Add multi-credential S3 auth support
Implement Option B (enhanced env var) for T058.S2:
- Support multiple S3 credentials via S3_CREDENTIALS env var
- Format: "key1:secret1,key2:secret2,..."
- Backward compatible with S3_ACCESS_KEY_ID/S3_SECRET_KEY
- Add tests for both multi and single credential formats

This unblocks T039 production deployment while proper IAM
credential service (T060) is implemented separately.

Tests: 10/10 auth tests pass (added 2 new credential tests)

Refs: T058.S2 Option B (approved), T060 (proper IAM integration)
2025-12-12 06:41:09 +09:00

94 lines
3.3 KiB
YAML

id: T058
name: LightningSTOR S3 Auth Hardening
goal: Implement robust SigV4 authentication for LightningSTOR S3 API
status: active
priority: P0
owner: peerB
created: 2025-12-12
depends_on: [T047]
blocks: [T039]
context: |
**Findings from T047 Completion Report:**
- SigV4 authentication middleware is active but signature validation fails due to canonicalization mismatch.
- Auth was bypassed (`S3_AUTH_ENABLED=false`) for T047 completion.
- This is a critical security vulnerability for production S3 API.
**Foreman Recommendation:**
- "Address the critical security issue in T047-lightningstor-s3 regarding SigV4 authentication."
acceptance:
- SigV4 authentication fully functional and passes AWS CLI tests.
- S3 API rejects invalid signatures.
- IAM integration for credentials.
steps:
- step: S1
name: Debug SigV4 Canonicalization
done: Identify and fix the canonicalization mismatch in SigV4 signature verification.
status: complete
completed: 2025-12-12 06:15 JST
owner: peerB
priority: P0
notes: |
**Root Cause Identified:**
- Used `form_urlencoded::byte_serialize` which follows HTML form encoding rules
- AWS SigV4 requires RFC 3986 URI encoding with specific rules
- Encoding mismatch caused canonical request hash to differ from client's
**Fix Implemented:**
- Created `aws_uri_encode()` matching RFC 3986 + AWS SigV4 spec exactly
- Unreserved chars (A-Z,a-z,0-9,-,_,.,~) are NOT encoded
- All other chars percent-encoded with uppercase hex (%2F not %2f)
- Preserve slashes in paths, encode in query parameters
- Normalize empty paths to '/' per AWS specification
**Testing:**
- All 8 auth unit tests pass
- Added comprehensive SigV4 signature determinism test
- Fixed test expectations (body hash, HMAC values)
**Files Modified:**
- lightningstor/crates/lightningstor-server/src/s3/auth.rs (~40L changes)
outputs:
- path: lightningstor/crates/lightningstor-server/src/s3/auth.rs
note: SigV4 canonicalization fix
- step: S2
name: Integrate with IAM
done: Fetch IAM credentials for signature verification.
status: in_progress
owner: peerB
priority: P1
notes: |
**Architecture Gap Identified (2025-12-12 06:37 JST):**
- IAM lacks S3 credential storage API (access_key_id, secret_key)
- Current services: IamAuthz, IamToken, IamAdmin (no credential management)
- Current implementation uses env vars (S3_ACCESS_KEY_ID, S3_SECRET_KEY)
**Proposed Options:**
A) Extend IAM with IamCredential service (~200-300L, 2-3 days)
B) Enhanced env var MVP (~20L, supports multiple credentials)
C) Defer S3 auth (risky - security gap)
**Status:** Blocked pending architectural decision from PeerA
- step: S3
name: Security Testing
done: Add comprehensive security tests for S3 authentication.
status: pending
owner: peerB
priority: P1
evidence:
- cmd: "cargo test --package lightningstor-server --lib s3::auth::tests"
result: "8 passed; 0 failed"
notes: |
Critical for production security of the S3 object storage. Blocking T039 for a truly secure deployment.
**S1 Complete (2025-12-12 06:15 JST):**
- RFC 3986 compliant URI encoding implemented
- All auth tests passing
- Ready for IAM integration (S2)