July 27th, 2024

Revealing the Inner Structure of AWS Session Tokens

A study by Tal Be'ery reverse-engineered AWS Session Tokens, revealing their structure and developing tools for analysis. This research aids security professionals in understanding AWS's authentication protocols to prevent attacks.

Read original articleLink Icon
Revealing the Inner Structure of AWS Session Tokens

A recent study by Tal Be'ery has successfully reverse-engineered AWS Session Tokens, previously considered opaque. This research reveals the internal structure of these tokens, which are crucial for AWS's security model, allowing for temporary, limited-privilege credentials. The study highlights the importance of understanding AWS's authentication and authorization protocols, especially as attackers often exploit these systems to gain unauthorized access. The AWS Security Token Service (STS) provides short-term credentials that include an ID, Secret, and a Session Token, which is encrypted and contains a validity period to mitigate risks associated with credential theft.

The research process involved decoding the Session Token, revealing a structured format that can be analyzed and manipulated. Be'ery's team developed two open-source tools: the AWS Token Decoder, which parses the token into fields, and the STS-token-decoder, which allows for programmatic analysis and synthesis of tokens. These tools enable users to efficiently analyze multiple tokens and modify them as needed, enhancing the understanding of AWS's security mechanisms.

The findings emphasize the need for defenders to comprehend the intricacies of AWS's authentication systems to better protect against potential attacks. The research not only sheds light on the cryptographic and authentication protocols used by AWS but also provides valuable resources for security professionals to analyze and improve their defenses against credential-based attacks.

Link Icon 6 comments
By @QuadmasterXLII - 6 months
Apparently medium has two seperate “do you want an account” popups now to click out of before you can read. This is a common problem once the development team for a website grows beyond a certain size- the left hand doesn’t know what the right hand is doing. Perhaps we can find the two project leads implementing them, have them fight to the death in some sort of saw trap, and the survivor gets to keep their javascript asking for my email address?
By @1659447091 - 6 months
> Following this revelation, we were able to observe that these keys change on an hourly basis...

Is it recommended to rotate keys hourly, or even daily? Or only for something like AWS - I've read/been told monthly is more than adequate for reg. web apps

By @Scaevolus - 6 months
I'm skeptical of there being any security implications. Signed but not encrypted tokens are effectively plaintext metadata, and token revocation is still an important operation on the service side, preventing zombie token attacks.

Reading metadata can be useful to know when a token is expired without hitting a remote service.

By @Chris2048 - 6 months
Hmm, is this structure shared by all AWS-service session tokens? e.g. Amazon-Connect tokens etc.
By @Dachande663 - 6 months
tl;dr it’s a standard protobuf payload after ignoring the first byte.