-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lambda functions with s3 event sources are publically accessible #1039
Comments
… setting SourceAccount when creating lambda resource policy.
fix zappa#1039 prohibit public access to created lambda functions by…
Thanks for fixing this, @ghostmaster-ai are you working to bring your work from Zappa2 back into Zappa now it has been undeprecated? |
I've had to adjust this manually as well in the past.
|
Hi there! Unfortunately, this Issue has not seen any activity for at least 90 days. If the Issue is still relevant to the latest version of Zappa, please comment within the next 10 days if you wish to keep it open. Otherwise, it will be automatically closed. |
Hi there! Unfortunately, this Issue was automatically closed as it had not seen any activity in at least 100 days. If the Issue is still relevant to the latest version of Zappa, please open a new Issue. |
Context
AWS Security Hub flags Zappa deployed lambda functions with an s3 event source as allowing public access.
Expected Behavior
While I'm not sure this satisfies cases where there are multiple AWS accounts involved, it seems to me the default behavior should be to create private lambda functions by including the AWS:SourceAccount in the lambda resource policy conditions as shown in my steps to reproduce below.
Actual Behavior
Zappa creates lambdas that can be invoked by anyone in control of the s3 bucket leading to AWS Security Hub flagging a security finding.
Possible Fix
I'm still looking into it, but for zappa deploy and update, we call core.create_event_permission. This method calls the lambda client add_permission method. If updated to include the SourceAccount argument with the account id the resource policy is created as expected during deploys and updates.
Steps to Reproduce
Since s3 buckets are involved and names are global, you'll need to edit references to the s3 bucket name in the below steps
Your Environment
pip freeze
: argcomplete==1.12.3boto3==1.18.42
botocore==1.21.42
certifi==2021.5.30
cfn-flip==1.2.3
charset-normalizer==2.0.5
click==8.0.1
durationpy==0.5
future==0.18.2
hjson==3.0.2
idna==3.2
jmespath==0.10.0
kappa==0.6.0
pep517==0.11.0
pip-tools==6.2.0
placebo==0.9.0
python-dateutil==2.8.2
python-slugify==5.0.2
PyYAML==5.4.1
requests==2.26.0
s3transfer==0.5.0
six==1.16.0
text-unidecode==1.3
toml==0.10.2
tomli==1.2.1
tqdm==4.62.2
troposphere==3.0.3
urllib3==1.26.6
Werkzeug==0.16.1
wsgi-request-logger==0.4.6
zappa==0.53.0
zappa_settings.json
:See steps to reproduce
The text was updated successfully, but these errors were encountered: