For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-s3-bucket-allows-restore-actions-from-all-principals.md.
A documentation index is available at /llms.txt.
S3 bucket policies must not allow restore actions to all principals (*). A public Allow on restore operations lets anyone trigger restores of archived objects, risking exposure of sensitive archived data and unexpected costs. Check AWS::S3::BucketPolicy resources’ Properties.PolicyDocument.Statement entries and flag any statement where Effect: "Allow", Principal: "*", and Action includes restore operations such as s3:RestoreObject.
To remediate, restrict Principal to explicit AWS principals (account IDs, ARNs, or specific roles), or remove restore actions from publicly allowed statements.
Secure configuration example restricting restore actions to a specific role:
#this code is a correct code for which the query should not find any resultResources:SampleBucketPolicy1:Type:'AWS::S3::BucketPolicy'Properties:Bucket:!Ref DOC-EXAMPLE-BUCKETPolicyDocument:Statement:- Action:- 's3:RestoreObject'Effect:DenyResource:'*'Principal:'*'Condition:StringLike:'aws:Referer':- 'http://www.example.com/*'- 'http://example.net/*'
#this is a problematic code where the query should report a result(s)Resources:SampleBucketPolicy3:Type:'AWS::S3::BucketPolicy'Properties:Bucket:!Ref DOC-EXAMPLE-BUCKETPolicyDocument:Statement:- Action:"RestoreObject"Effect:AllowResource:"*"Principal:"*"Condition:StringLike:'aws:Referer':- 'http://www.example.com/*'- 'http://example.net/*'SampleBucketPolicy4:Type:'AWS::S3::BucketPolicy'Properties:Bucket:!Ref DOC-EXAMPLE-BUCKETPolicyDocument:Statement:- Action:- "RestoreObject"- "GetObject"Effect:AllowResource:"*"Principal:"*"Condition:StringLike:'aws:Referer':- 'http://www.example.com/*'- 'http://example.net/*'