Missing Authentication on Aws
How Missing Authentication Manifests in Aws
Missing authentication in Aws applications creates critical security vulnerabilities that attackers can exploit to gain unauthorized access to sensitive data and functionality. In Aws, this vulnerability often appears in Lambda functions, API Gateway endpoints, and containerized services deployed on ECS or EKS.
One common manifestation occurs when Aws Lambda functions lack proper authentication checks. Consider a function that processes sensitive business data but doesn't verify the caller's identity:
exports.handler = async (event) => {
const data = await processSensitiveData();
return { statusCode: 200, body: JSON.stringify(data) };
};
An attacker can invoke this function directly through the Aws Lambda API or by triggering it through configured event sources, bypassing any intended access controls.
API Gateway endpoints without authentication represent another critical attack surface. When an API Gateway method lacks an authorizer, anyone with the endpoint URL can access the backend service:
{
"x-amazon-apigateway-integration": {
"uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789012:function:my-function/invocations",
"httpMethod": "POST"
}
}
Without an authorizer configuration, this endpoint exposes the Lambda function to the public internet.
Containerized applications on ECS or EKS often suffer from missing authentication in service-to-service communication. A microservice might expose an internal endpoint without authentication, assuming network isolation provides security:
from flask import Flask, request
app = Flask(__name__)
@app.route('/internal-data', methods=['GET'])
def get_internal_data():
# No authentication check
return get_sensitive_data()
If this container is accidentally exposed through a misconfigured load balancer or network policy, attackers gain direct access to internal APIs.
Aws Amplify applications frequently exhibit missing authentication in GraphQL resolvers. Developers sometimes forget to add authentication checks to resolver functions:
const resolvers = {
Query: {
getUserData: async (parent, args, context) => {
// Missing authentication check
return await getUserDataFromDatabase(args.id);
}
}
};
This allows anyone who can reach the GraphQL endpoint to query user data without authentication.
Aws-Specific Detection
Detecting missing authentication in Aws environments requires examining both infrastructure configurations and application code. For Lambda functions, check the resource-based policies to see if they allow public invocation:
aws lambda get-policy --function-name my-function
Look for statements with Principal set to "*" or statements allowing "lambda:InvokeFunction" from untrusted sources.
For API Gateway, examine the API configuration to verify authentication methods are properly configured:
aws apigateway get-authorizers --rest-api-id my-api-id
Each method should have an authorizer attached, typically a Cognito user pool, Lambda authorizer, or IAM role.
Network configurations require careful review to ensure services aren't accidentally exposed. Check security group rules and network ACLs:
aws ec2 describe-security-groups --filters Name=group-name,Values="*my-service*"
Look for overly permissive rules like "0.0.0.0/0" or "::/0" that allow unrestricted access.
middleBrick's Aws-specific scanning detects missing authentication by analyzing the runtime behavior of your API endpoints. The scanner tests unauthenticated access to all exposed endpoints and identifies those that respond without proper authentication challenges.
The scanner examines API Gateway configurations, Lambda function policies, and network exposure to provide a comprehensive assessment. For each finding, middleBrick provides the specific endpoint URL, the type of missing authentication, and remediation guidance tailored to Aws services.
middleBrick also analyzes OpenAPI specifications against actual runtime behavior, identifying discrepancies where documentation shows authentication requirements but the implementation doesn't enforce them. This is particularly valuable for Aws applications where infrastructure-as-code templates might specify authentication that isn't properly implemented in the application code.
Aws-Specific Remediation
Remediating missing authentication in Aws requires implementing proper authentication mechanisms at both the infrastructure and application levels. For Lambda functions, add IAM policy restrictions to limit invocation:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "apigateway.amazonaws.com"
},
"Action": "lambda:InvokeFunction",
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:my-function"
}
]
}
This ensures only API Gateway can invoke the function, not arbitrary clients.
For API Gateway, implement Cognito user pool authorizers for user-facing APIs:
{
"type": "COGNITO_USER_POOLS",
"providerARNs": ["arn:aws:cognito-idp:us-east-1:123456789012:userpool/us-east-1_abc123"]
}
For service-to-service communication, use Lambda authorizers or IAM roles with least privilege.
Containerized applications should implement JWT authentication middleware:
const jwt = require('jsonwebtoken');
function authenticateJWT(req, res, next) {
const token = req.headers.authorization?.split(' ')[1];
if (!token) {
return res.status(401).json({ message: 'Missing token' });
}
jwt.verify(token, process.env.JWT_SECRET, (err, user) => {
if (err) {
return res.status(403).json({ message: 'Invalid token' });
}
req.user = user;
next();
});
}
Apply this middleware to all protected routes.
For GraphQL APIs, add authentication checks to all resolvers:
const resolvers = {
Query: {
getUserData: async (parent, args, context) => {
if (!context.user) {
throw new Error('Authentication required');
}
return await getUserDataFromDatabase(args.id);
}
}
};
middleBrick's remediation guidance provides specific recommendations for Aws services, including IAM policy templates, Cognito configuration examples, and integration patterns for different authentication methods.
For continuous monitoring, implement AWS Config rules to detect when authentication configurations drift from their intended state. Create rules that check for public Lambda function policies, unauthenticated API Gateway methods, and overly permissive security groups.
Related CWEs: authentication
| CWE ID | Name | Severity |
|---|---|---|
| CWE-287 | Improper Authentication | CRITICAL |
| CWE-306 | Missing Authentication for Critical Function | CRITICAL |
| CWE-307 | Brute Force | HIGH |
| CWE-308 | Single-Factor Authentication | MEDIUM |
| CWE-309 | Use of Password System for Primary Authentication | MEDIUM |
| CWE-347 | Improper Verification of Cryptographic Signature | HIGH |
| CWE-384 | Session Fixation | HIGH |
| CWE-521 | Weak Password Requirements | MEDIUM |
| CWE-613 | Insufficient Session Expiration | MEDIUM |
| CWE-640 | Weak Password Recovery | HIGH |