null (Service: AWSKMS; Status Code: 400; Error Code: AccessDeniedException; Request ID: xxx; Proxy: null)
Trying to grant access an organizational unit access to a KMS key
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⚙️ Check out my series on Automating Cybersecurity Metrics | Code.
🔒 Related Stories: Bugs | AWS Security | Secure Code
💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Right now I’m trying to give an organizational unit access to a KMS key. I’ve followed various different sources of documentation and this is the error I get:
null (Service: AWSKMS; Status Code: 400; Error Code: AccessDeniedException; Request ID: 51440912–11e7–4d72–8543-a5ffafe2e477; Proxy: null)One problem was that I did not have the brackets [ ] in the exact right place in the json hierarchy.
"Condition":{
"ForAnyValue:StringLike":{
"aws:PrincipalOrgPaths":[
"o-1122334455/r-abcd/ou-1/",
"o-1122334455/r-abcd/ou-2/"
]
}
}Whatever code is processing the request to access the key is expecting an array of values in [] like [a, b, c] not a single value “a” without brackets or a list like this “a”, “b” with no brackets.
The code is expecting one nested condition “aws:PrincipalOrgPaths” for the StringLike condition, not an array [ “aws:PrincipalOrgPaths”, “x”, “y”].
I had the [ and ] around aws:PrinicpalOrgPaths instead of where it is around the two organizations here.
Code is picky!
Fix: It would be nicer if the KMS policy editor caught this error before saving in its validation routine.I also found it helpful to use the asterisk in the org path like this where the first value is the organization id and the last value is the OU ID, both which are found in the AWS Organizations section of the AWS portal.
"Condition":{
"ForAnyValue:StringLike":{
"aws:PrincipalOrgPaths":[
"o-1122334455/*/ou-1/",
"o-1122334455/*/ou-2/"
]
}
}Resources:
I tried to add a key to an SSM parameter in another account with a different key and got the same error. Somewhere along the way I realized I was using the wrong key, so probably I have this same problem in some other key policy and/or this error occurs simply because access is denied.
Follow for updates.
Teri Radichel | © 2nd Sight Lab 2022
About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight LabNeed Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for PresentationFollow for more stories like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
❤️ Sign Up my Medium Email List
❤️ Twitter: @teriradichel
❤️ LinkedIn: https://www.linkedin.com/in/teriradichel
❤️ Mastodon: @teriradichel@infosec.exchange
❤️ Facebook: 2nd Sight Lab
❤️ YouTube: @2ndsightlab
