fix(security): scope row locks and add explicit expiry recovery

This commit is contained in:
2026-11-20 19:51:42 +03:00
parent 93e5a915d5
commit 5c91f605fb
12 changed files with 193 additions and 26 deletions
+32 -11
View File
@@ -652,18 +652,39 @@ print(json.dumps({{'job_id':k,'hashes':{{r['name']:r['sha256'] for r in hashes}}
a, j = upload()
confirm(a, j)
key = f"objects/{a['id']}/v1/original"
security = inside(f"""from minio.error import S3Error
from urllib.error import HTTPError
try: urllib.request.urlopen('http://s3:9000/'+BUCKET+'/' + {key!r},timeout=3)
except HTTPError as e: anonymous=e.code
else: raise AssertionError('Anonymous access allowed')
code = f"""import io,json,urllib3
from uuid import uuid4
from minio import Minio
from minio.credentials import StaticProvider
from minio.error import S3Error
from src.security_probe import context,values,exchange,denied
request=b'GET /messenger/{key} HTTP/1.1\\r\\nHost: s3\\r\\nConnection: close\\r\\n\\r\\n'
anonymous=denied(lambda:exchange('s3',9443,None,request))
v=values('worker');pool=urllib3.PoolManager(ssl_context=context('worker'),retries=False,timeout=urllib3.Timeout(connect=2,read=4))
client=Minio('s3:9443',credentials=StaticProvider(v['S3_ACCESS_KEY'],v['S3_SECRET_KEY']),secure=True,http_client=pool,region='us-east-1')
denials={{}}
for name,fn in [('create_bucket',lambda:store.client.make_bucket('forbidden-'+uuid4().hex)),('write_outside_prefix',lambda:store.client.put_object(BUCKET,'outside-'+uuid4().hex,io.BytesIO(b'x'),1)),('list_other_bucket',lambda:list(store.client.list_objects('forbidden-'+uuid4().hex)))]:
try: fn()
except S3Error as e: denials[name]=e.code
else: raise AssertionError('IAM allowed forbidden action')
print(json.dumps({{'anonymous':anonymous,'iam':denials}}))""")
assert security["anonymous"] == 403 and set(
try:
for name,fn in [('create_bucket',lambda:client.make_bucket('forbidden-'+uuid4().hex)),('write_outside_prefix',lambda:client.put_object('messenger','outside-'+uuid4().hex,io.BytesIO(b'x'),1)),('list_other_bucket',lambda:list(client.list_objects('forbidden-'+uuid4().hex)))]:
try: fn()
except S3Error as error: denials[name]=error.code
else: raise AssertionError('Worker was allowed a forbidden S3 operation')
print(json.dumps({{'anonymous_tls_denied':anonymous,'iam':denials}}))
finally:pool.clear()
"""
compile(code, "scoped-s3-negative-probe", "exec")
security = json.loads(
compose(
"--profile",
"operator",
"run",
"--rm",
"--no-deps",
"operator-probe",
"-c",
code,
)
)
assert security["anonymous_tls_denied"] and set(
security["iam"].values()
) == {"AccessDenied"}
selected = None