-file-..-2f..-2f..-2f..-2fhome-2f-2a-2f.aws-2fcredentials
-file-../../../home/*/.aws/credentials
The .aws/credentials file is created by the AWS CLI, SDKs, and tools like aws configure. It stores:
[default]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
With these keys, an attacker can:
That’s why credentials is a crown jewel for attackers. -file-..-2F..-2F..-2F..-2Fhome-2F-2A-2F.aws-2Fcredentials
# Sanitize user input
import os
def sanitize_path(user_input):
# Reject path traversal sequences
if '..' in user_input or user_input.startswith('/'):
raise ValueError("Invalid path")
return os.path.basename(user_input)
At first encounter, the string -file-..-2F..-2F..-2F..-2Fhome-2F-2A-2F.aws-2Fcredentials looks like gibberish. However, to a security professional or a seasoned developer, it immediately raises red flags. This is an obfuscated path traversal payload targeting one of the most sensitive files on a Unix-based system: the AWS credentials file.
In this article, we will:
../
..%2F
..%252F
.aws/credentials
/etc/passwd
/home/*/
The -2A decodes to *. If the application globs the path (e.g., using glob.glob() in Python), */.aws/credentials would match:
The attacker may not know the exact username, so they use * to try all possibilities. If the application returns the first match or concatenates contents, the attack succeeds. -file-
The attempt to access ~/.aws/credentials via a path traversal vulnerability highlights the need for robust security practices, especially regarding sensitive file access and credential management. It's crucial for developers and administrators to implement secure coding practices and regularly audit their environments to protect against such threats.