feat: confine a compromised worker and drill its compromise end to end
- narrow the worker S3 user to staging reads and attachments writes - add database rules the worker role cannot bypass: no return to pending, variant keys of its own attachment, known error codes only - let the cleaner remove a ready source only after its own SHA-256 check - add make jobs_audit [REPAIR=1] to name and requeue damaged jobs - add make worker_compromise: isolated before/after stands, one operation table, response windows, job safety, controls and committed hypotheses Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2351,6 +2351,25 @@ S3_REQUIRED_ROWS = (
|
||||
"cleaner key list attachments prefix",
|
||||
"cleaner key list staging prefix",
|
||||
"cleaner key list database prefix",
|
||||
# префиксы ключа worker (change track1-worker-compromise, решение 5)
|
||||
"worker key get other database",
|
||||
"worker key put other database",
|
||||
"worker key get bucket root",
|
||||
"worker key put bucket root",
|
||||
"worker key copy from attachments",
|
||||
"worker key copy from other database",
|
||||
"worker key copy from attachments by dotted path",
|
||||
"worker key batch delete",
|
||||
"staging content after worker requests",
|
||||
)
|
||||
# те же строки у базы стенда и её тестовой пары
|
||||
S3_REQUIRED_DATABASE_ROWS = (
|
||||
"worker key get {}/staging",
|
||||
"worker key put {}/attachments",
|
||||
"worker key get {}/attachments",
|
||||
"worker key put {}/staging",
|
||||
"worker key delete {}/attachments",
|
||||
"worker key delete {}/staging",
|
||||
)
|
||||
# слушающие сокеты контейнера S3 (busybox netstat образа): вне loopback
|
||||
# должны быть только API S3 и gRPC шлюза, остальные — только на loopback.
|
||||
@@ -2609,6 +2628,7 @@ def s3_stand() -> dict[str, str]:
|
||||
"port": str(published["target"]),
|
||||
"out_port": str(published["published"]),
|
||||
"bucket": str(services["s3-bootstrap"]["environment"]["S3_BUCKET"]),
|
||||
"database": str(api_env["DATABASE__NAME"]),
|
||||
}
|
||||
|
||||
|
||||
@@ -2707,7 +2727,15 @@ def cmd_s3_check() -> int:
|
||||
problems.append(f"s3-bootstrap check exited with {rc}")
|
||||
# bootstrap печатает строки сам; прежний bootstrap.sh их не напечатает
|
||||
seen_rows = {row[1] for row in rows}
|
||||
for name in S3_REQUIRED_ROWS:
|
||||
database = stand["database"]
|
||||
for name in (
|
||||
*S3_REQUIRED_ROWS,
|
||||
*(
|
||||
row.format(name)
|
||||
for row in S3_REQUIRED_DATABASE_ROWS
|
||||
for name in (database, f"test_{database}")
|
||||
),
|
||||
):
|
||||
if name not in seen_rows:
|
||||
problems.append(f"no row from s3-bootstrap check: {name}")
|
||||
# с хоста — HTTPS на localhost (SAN identity s3) с CA стенда
|
||||
@@ -3688,7 +3716,7 @@ SELECT pg_temp.driver_try('second variant of the name', $q$
|
||||
object_key, content_type, size_bytes, width, height, sha256,
|
||||
created_at)
|
||||
SELECT attachment_id, pipeline_version, variant,
|
||||
object_key || '-probe', content_type, size_bytes, width, height,
|
||||
object_key || 'probe', content_type, size_bytes, width, height,
|
||||
sha256, now()
|
||||
FROM attachment_variants WHERE attachment_id = '{attachment_id}'
|
||||
$q$) \\g /dev/null
|
||||
@@ -3698,7 +3726,7 @@ SELECT pg_temp.driver_try('error_code on not failed', $q$
|
||||
updated_at, created_at)
|
||||
SELECT gen_random_uuid(), chat_id, owner_id, filename, content_type,
|
||||
size_bytes, sha256, object_key || '-probe', staging_key, status,
|
||||
'probe', now(), now()
|
||||
'invalid_image', now(), now()
|
||||
FROM attachments WHERE id = '{attachment_id}'
|
||||
$q$) \\g /dev/null
|
||||
SELECT pg_temp.driver_try('replay audit of an unknown job', $q$
|
||||
|
||||
Reference in New Issue
Block a user