Missing Tls in Adonisjs with Dynamodb
Missing Tls in Adonisjs with Dynamodb — how this specific combination creates or exposes the vulnerability
When an AdonisJS application communicates with Amazon DynamoDB without enforcing Transport Layer Security (TLS), credentials, tokens, and potentially sensitive data can traverse the network in cleartext. This specific combination is risky because AdonisJS often manages long-lived processes and may cache SDK clients; if the DynamoDB client is instantiated without explicit TLS settings or against an HTTPS endpoint, requests may fall back to HTTP depending on environment or SDK defaults. Attackers on the same network or who can intercept traffic can capture IAM credentials embedded in requests, abuse overly permissive IAM policies, or manipulate data in transit.
In a black-box scan, middleBrick tests unauthenticated endpoints and configurations; for AdonisJS services that expose API routes or admin panels interacting with DynamoDB, missing TLS can be detected when responses or configuration references non-HTTPS endpoints. Real-world attack patterns include credential harvesting via compromised internal networks and SSRF-assisted extraction where an attacker coerces the app into sending DynamoDB requests over cleartext HTTP to a malicious listener. Findings align with OWASP API Top 10 items related to broken object level authorization and excessive data exposure, and may map to compliance frameworks such as PCI-DSS and SOC2 that require encryption in transit.
middleBrick’s LLM/AI Security checks do not apply here, but the scanner’s 12 parallel checks will flag Missing TLS when API behaviors or spec-defined endpoints indicate cleartext communication risks. By scanning your AdonisJS-integrated DynamoDB surface, the tool provides prioritized findings with severity, guidance, and references to secure configuration practices without assuming internal architecture.
Dynamodb-Specific Remediation in Adonisjs — concrete code fixes
Ensure the AWS SDK used by your AdonisJS service enforces HTTPS for all DynamoDB calls. Configure the SDK with explicit TLS settings and avoid environment-driven fallback to insecure endpoints. Below are concrete, working code examples for AdonisJS that demonstrate how to initialize the DynamoDB client with TLS enforcement and use it securely.
import { DynamoDB } from '@aws-sdk/client-dynamodb';
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
import { fromEnv } from '@aws-sdk/credential-providers';
// Enforce TLS by ensuring HTTPS is used and disabling fallback to HTTP
const client = new DynamoDB({
region: process.env.AWS_REGION || 'us-east-1',
credentials: fromEnv(),
endpoint: process.env.DYNAMODB_ENDPOINT ? new URL(process.env.DYNAMODB_ENDPOINT) : undefined,
tls: true,
requestHandler: {
httpsAgent: new (require('https').Agent)({
rejectUnauthorized: true,
}),
},
});
const docClient = DynamoDBDocument.from(client);
// Example: Secure put item with explicit TLS context
export async function storeRecord(table: string, item: Record) {
try {
await docClient.put({
TableName: table,
Item: item,
});
console.log('Stored securely with TLS');
} catch (error) {
console.error('DynamoDB put error:', error);
throw error;
}
}
// Example: Secure get item
export async function getRecord(table: string, key: Record) {
const result = await docClient.get({
TableName: table,
Key: key,
});
return result.Item;
}
Additionally, validate endpoint URLs to ensure they use HTTPS and avoid constructing endpoints from user-controlled input without strict validation. For environments that use IAM roles, keep the SDK’s default credential chain but ensure runtime policies require encrypted transport. middleBrick’s dashboard and CLI can be used to verify that no insecure HTTP endpoints are present in your configuration; the GitHub Action can enforce a minimum security score threshold to block deployments that expose Missing TLS findings.
When using the middleBrick MCP Server from an AI coding assistant, you can trigger scans directly from your IDE to validate that TLS settings remain intact after changes. Combine this with the Web Dashboard to track scores over time and the Pro plan’s continuous monitoring to detect regressions early. Remediation guidance provided by middleBrick includes mapping findings to OWASP API Top 10 and compliance references so teams can implement precise fixes.
Related CWEs: encryption
| CWE ID | Name | Severity |
|---|---|---|
| CWE-319 | Cleartext Transmission of Sensitive Information | HIGH |
| CWE-295 | Improper Certificate Validation | HIGH |
| CWE-326 | Inadequate Encryption Strength | HIGH |
| CWE-327 | Use of a Broken or Risky Cryptographic Algorithm | HIGH |
| CWE-328 | Use of Weak Hash | HIGH |
| CWE-330 | Use of Insufficiently Random Values | HIGH |
| CWE-338 | Use of Cryptographically Weak PRNG | MEDIUM |
| CWE-693 | Protection Mechanism Failure | MEDIUM |
| CWE-757 | Selection of Less-Secure Algorithm During Negotiation | HIGH |
| CWE-261 | Weak Encoding for Password | HIGH |
Frequently Asked Questions
How can I verify that my AdonisJS app is using TLS with DynamoDB?
middlebrick scan <your-api-url> and review findings for Missing TLS. Additionally, inspect your SDK configuration to ensure tls: true and HTTPS endpoints are set, and confirm that no environment variables override to HTTP.