Allow unquoted account ids in IAM Policies #6662
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Allow unquoted AWS account ids in IAM Policies
Motivation and Context
IAM Policies with unquoted (numeric) AWS account ids are considered valid by IAM and work as intended, however, our existing IAM Policy reader/validation considers these invalid. Additionally, IAM considers unquoted boolean values in conditions as valid, but these are also rejected by the current SDK validation.
Reference: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies.html
Modifications
This PR loosens validations in limited contexts where either unquoted accountIDs or booleans may appear and be valid - these are limited to Principals and Conditions only. Principals may have unquoted accountIds and Conditions may have unquoted account ids and booleans.
Note that although AWS account ids may have leading zeros, IAM will reject Policy Documents with unquoted account ids with leading zeros - these are invalid JSON and are not supported - server side validation rejects these. Policy documents with these will still be considered invalid by the SDK reader.
Testing
New and existing unit tests.
Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License