-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(s3-notifications): s3 notifications not publishing to sns #28012
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oddly, when you create the S3 notification via the Console no Conditions are created but it still works.
They are never necessary.
One might argue they prevent a confused deputy attack, but since we already have a condition on aws:SourceArn
, that confused deputy attack is already prevented.
I'm also concerned that if someone calls Bucket.fromBucketArn()
, we won't correctly parse the Account ID from the ARN (given that an S3 Bucket's ARN does not contain the account ID), and adding this additional condition is going to break some people's code.
I'm seeing no upside, and only downside to merging this. Anyone feel differently?
This is fixing a bug. As written, S3 notifications don't successfully trigger to SNS. |
Hi Mike, At the risk of repeating myself, For example: {
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "*",
"Principal": "You"
} Means: "you can read any S3 object". In contrast: {
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "*",
"Principal": "You",
"Condition": {
"IpAddress": {"aws:SourceIp": "1.2.3.4"}
}
} Means: "you can read any S3 object, but ONLY if you are making API calls from See how the That's why adding a
Now, I believe you if you say the statement is not working (although it's a bit odd that it would. It sure seems like it should have worked at some point, I wonder if something has changed?). Our job is to figure out why the statement is not working as it is. I see in the documentation that the recommended ARN pattern has
This looks super odd to me, as S3 ARNs normally don't have anything in those locations blanked out by the
As you can see, it doesn't have Can you try that? Can you try building an ARN that has the Once we have the condition on The only reason these statements are in here to prevent a Confused Deputy attack. The attack goes as follows:
The way to mitigate this attack is add the If we have that protection, do we need to add the 🤷 It's always hard to argue against more protection, because you never know when you might need it. But my guess would be no. |
(Now of course, all of what I said could easily be invalidated by a single additional |
@rix0rrr – I 100% agree with you: adding a condition should not make this work. That said, I tested again with the current code and I can get messages to fire to SNS. When I tried last week, it was not working until I added the code in the PR. It wasn't working for @rkraman-leo as well, who originally filed the issue. @rix0rrr, is it possible to check if there was a bug or issue last week that caused this to break? @rkraman-leo – Can you verify that you can get messages to publish to SNS with the current code? |
Aha! Is what you're saying, even without the fix in this PR the code magically started working again? I'll create an internal ticket to ask around. |
@rix0rrr yup, I tested in two different Regions and it's working. It was for sure buggy last week though, it would not trigger SNS. |
Huh. If you have an approximate date and time, and a region you observed this behavior in, that would be helpful |
@rix0rrr It was in Oregon, ~30 minutes before the PR was opened. 😅 |
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
Apologies for getting back late on this. Ref:
After I changed the S3 prefix in the event notification from "business_config_snapshot/schemaVersion=1/" to "business_config_snapshot/schemaVersion%3D1/", it worked for me. |
@rix0rrr I think this can be closed unless we want to close the loop with the S3 team if there was a glitch in sending notifications to SNS. |
This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error. |
I tested the integration test with
--no-clean
and it successfully published.Oddly, when you create the S3 notification via the Console no
Conditions
are created but it still works.Maybe both are needed if you include one. 😓
Closes #27994.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license