SQS DLQ Policy Auditor
Mindset
One-line takeaway: the verdict is always the worst finding across
five dimensions, and three SQS behaviours catch even experienced engineers —
Principal: "*" in a queue policy is usually safe (S3/SNS notification
pattern), maxReceiveCount counts per delivery not per consumer, and
RedrivePolicy is a JSON-encoded string that must be parsed before
classification.
A dead-letter queue is the only safety net against poison-pill messages. A
queue without a DLQ silently retries bad messages until they expire, burning
through compute budget and starving healthy messages. Public queue policies
expose message payloads to any AWS account. Missing encryption leaves message
bodies in plaintext at rest.
Quick reference — verdict thresholds
| Condition |
Verdict |
Risk |
Rule |
Principal: "*" + sqs:SendMessage/sqs:*/* + no strong condition |
PUBLIC_ACCESS |
CRITICAL |
Step 1 |
No RedrivePolicy attribute / missing deadLetterTargetArn |
NO_DLQ |
HIGH |
Step 2 |
Neither SqsManagedSseEnabled: true nor KmsMasterKeyId set |
NO_ENCRYPTION |
HIGH |
Step 3 |
maxReceiveCount <= 1 (too aggressive) |
CONFIG_GAP |
MEDIUM |
Step 4a |
maxReceiveCount > 1000 (poison-pill loop) |
CONFIG_GAP |
MEDIUM |
Step 4b |
DLQ MessageRetentionPeriod < 345600 (4 days) |
CONFIG_GAP |
MEDIUM |
Step 4c |
DLQ ARN in a different account + no RedriveAllowPolicy granting access |
CONFIG_GAP |
MEDIUM |
Step 4d |
| All dimensions pass |
OK |
LOW |
Step 5 |
See the ordered steps below for edge cases (Principal:"*" with SourceArn,
FIFO DLQ constraints, VisibilityTimeout interaction).
Pre-flight: queue metadata gate
Before evaluating the queue policy and redrive configuration, classify the
queue itself. Several attributes short-circuit or modify the audit.
Multi-queue / account-wide sweep note (pagination): aws sqs list-queues
returns up to 1000 queue URLs per page. Use --next-token (from the prior
NextToken) to page through all queues; iterating only the first page
silently misses queues. For each URL, aws sqs get-queue-attributes --queue-url <url> --attribute-names All returns all attributes in one call
(no pagination needed for attributes).
| Attribute |
Value |
Effect on audit |
FifoQueue |
true |
FIFO queue. DLQ must also be FIFO. maxReceiveCount tuning is MORE critical — a poison pill in a message group blocks the entire group until moved to DLQ. |
FifoQueue |
false / absent |
Standard queue. Normal audit. |
ContentBasedDeduplication |
true (FIFO) |
Deduplication runs before receive count — a retried message with the same dedup ID does NOT increment the counter. Poison pills persist longer than expected. |
Policy |
absent / empty |
No resource-based policy. Only IAM identity-based policies govern access. This is the SECURE default — do not flag as a gap. |
KmsMasterKeyId |
set |
SSE-KMS encryption. Customer-managed or AWS-managed KMS key. Encryption is satisfied. |
SqsManagedSseEnabled |
true |
SSE-SQS encryption. Amazon SQS-managed encryption (free, FIPS-compliant). Encryption is satisfied. |
If the queue attribute document is malformed (the Policy field is not
valid JSON, or RedrivePolicy is not valid JSON when present), output:
QUEUE: <queue-url>
VERDICT: ERROR
REASON: Queue attribute document is malformed — <field> is not valid JSON.
REMEDIATION: Re-fetch with `aws sqs get-queue-attributes --queue-url <url> --attribute-names All --output json` and re-audit.
RedrivePolicy is a JSON-encoded string, not a native attribute.
aws sqs get-queue-attributes returns RedrivePolicy as a
JSON-encoded string (double-encoded in the CLI JSON output). You MUST
parse the inner JSON before reading deadLetterTargetArn and
maxReceiveCount. A classification that reads the raw string as a dict
produces false NO_DLQ verdicts — the field looks absent because it was never
parsed.
Process — Classification logic (apply in order, aggregate worst)
Step 0: Expert knowledge — non-obvious SQS behaviours that change classification
Full catalog (Principal:"*" usually safe, per-delivery counting, FIFO group
blocking, SSE-SQS, RedriveAllowPolicy, VT window, ESM, v2 API, casing): references/advanced-patterns.md.
Step 1: Public access via queue policy (PUBLIC_ACCESS)
For each Effect: Allow statement in the queue policy, classify the
principal scope:
WILDCARD_PRINCIPAL — Principal: "*", Principal: {"AWS": "*"}, or
any construct resolving to all AWS principals.
NAMED_PRINCIPAL — Principal: {"AWS": "arn:aws:iam::ACCOUNT:role/..."}
or Principal: {"Service": "s3.amazonaws.com"}.
A WILDCARD_PRINCIPAL statement is classified by its condition strength:
STRONG conditions (NOT public — access is genuinely scoped):
aws:SourceArn (ArnEquals / ArnLike) — request must originate from
the named resource (S3 bucket, SNS topic). This is the standard S3/SNS-
to-SQS pattern. The caller cannot forge this; it is set by the AWS
service layer.
aws:SourceAccount (StringEquals) — request must originate from the
named account.
aws:SourceAws (deprecated alias of SourceAccount).
WEAK / NO conditions (PUBLIC — flag as PUBLIC_ACCESS):
- No
Condition block at all.
aws:SourceIp / aws:SourceIp containing 0.0.0.0/0 — IP-based
restrictions are bypassable; 0.0.0.0/0 is the entire internet.
aws:SourceVpce / aws:SourceVpc — VPC-scoped but the VPC endpoint is
network-reachable from peered connections; treat as WEAK for public-
exposure classification.
aws:Referer, aws:UserAgent — trivially forgeable by any HTTP client.
Action sensitivity for WILDCARD_PRINCIPAL with weak/no condition:
| Action |
Severity |
Why |
sqs:SendMessage |
CRITICAL |
Any account can inject messages — data poisoning, queue flooding, cost amplification. |
sqs:ReceiveMessage |
CRITICAL |
Any account can drain the queue — silent data exfiltration of message payloads. |
sqs:DeleteMessage |
CRITICAL |
Any account can delete messages — silent data loss. |
sqs:* / * |
CRITICAL |
Full queue control — inject, drain, delete, reconfigure. |
sqs:GetQueueAttributes / sqs:GetQueueUrl |
MEDIUM |
Metadata disclosure only (queue config, approximate message counts). Not PUBLIC_ACCESS verdict — note as advisory. |
If any WILDCARD_PRINCIPAL statement with a sensitive action (SendMessage,
ReceiveMessage, DeleteMessage, sqs:*, *) and a WEAK/NO condition is found,
the queue verdict is PUBLIC_ACCESS with CRITICAL risk.
Step 2: Dead-letter queue presence (NO_DLQ)
Evaluate the RedrivePolicy attribute (after JSON-parsing the string):
Absent / empty / malformed → NO_DLQ. No dead-letter queue is
configured. Poison-pill messages retry until MessageRetentionPeriod
expires (default 4 days). Every retry is a billable API call. With a high
maxReceiveCount (if somehow set without a DLQ — configuration drift),
the retry storm can last days.
Present but deadLetterTargetArn missing → NO_DLQ. The policy
JSON exists but the DLQ target is absent — the redrive is non-functional.
Present with deadLetterTargetArn → proceed to Step 4d (DLQ
accessibility sub-check).
FIFO queue special case: if FifoQueue: true and the deadLetterTargetArn
points to a standard (non-FIFO) queue, the redrive is INVALID — SQS silently
rejects messages to a standard DLQ from a FIFO source. Flag as NO_DLQ with
note: "DLQ ARN points to a standard queue — FIFO source requires a FIFO DLQ."
Step 3: Encryption-at-rest (NO_ENCRYPTION)
Evaluate encryption from two attributes:
SqsManagedSseEnabled: true → SSE-SQS is active. Encryption is
satisfied. This is the free, AWS-managed option (AES-256-GCM, FIPS-
validated). Do NOT flag.
KmsMasterKeyId set to a key ARN / key ID / alias → SSE-KMS is
active. Encryption is satisfied. Note whether the key is AWS-managed
(alias/aws/sqs) or customer-managed (for cost/rotation auditing — route
to kms-key-policy-auditor for the key policy).
Neither set → NO_ENCRYPTION. Message bodies are stored in
plaintext at rest. Messages are always encrypted in transit (TLS), but
the at-rest storage is unencrypted. Flag as HIGH risk.
Step 4: Configuration gaps (CONFIG_GAP sub-checks)
If no higher-severity verdict was triggered (PUBLIC_ACCESS, NO_DLQ,
NO_ENCRYPTION), evaluate the following sub-checks. Each finding is
enumerated; any non-empty finding set produces a CONFIG_GAP verdict.
Step 4a: maxReceiveCount too low
If maxReceiveCount (from the parsed RedrivePolicy) is <= 1:
maxReceiveCount: 1 → any transient failure (consumer crash, network
blip, Lambda throttle, VisibilityTimeout too short) sends the message
straight to the DLQ on the FIRST delivery attempt. This is almost always
a misconfiguration — the message never gets a second chance. High false-
positive DLQ rate.
maxReceiveCount: 2-3 with Lambda event source mapping → advisory. The
Lambda service's batch window adds delay between retries, so 2-3
invocations may be insufficient for transient downstream failures.
Flag as CONFIG_GAP with MEDIUM risk. Recommended: set to 5-10 for standard
queues, 5-15 for FIFO queues (message-group blocking makes retries cheaper).
Step 4b: maxReceiveCount too high
If maxReceiveCount > 1000:
- The message retries up to 1000+ times before reaching the DLQ. At a
VisibilityTimeout of 30s, that is ~8+ hours of retry cycles. Poison-pill
messages burn compute budget and starve healthy messages in the queue.
For FIFO queues, the message group is stalled for the entire duration.
Flag as CONFIG_GAP with MEDIUM risk. Recommended: 5-100 for standard queues,
5-20 for FIFO queues.
Step 4c: DLQ message-retention period too short
If the DLQ's MessageRetentionPeriod < 345600 (4 days):
- Failed messages expire from the DLQ before operations teams can analyse
and replay them. The DLQ is useless as a diagnostic tool if messages
vanish before anyone looks. The default retention (4 days / 345600s) is
already marginal for weekend coverage.
Flag as CONFIG_GAP with MEDIUM risk. Recommended: 1209600 (14 days, the
maximum) for DLQs to ensure weekend/holiday coverage.
If DLQ attributes are not provided in the input, note: "DLQ retention period
not provided — fetch with aws sqs get-queue-attributes --queue-url <dlq-url> --attribute-names MessageRetentionPeriod to verify."
Step 4d: Cross-account DLQ accessibility
If the deadLetterTargetArn in the RedrivePolicy points to a queue in a
different AWS account (12-digit account ID differs from the source queue's
account):
The DLQ is cross-account. SQS supports this IF the DLQ's queue policy (or
RedriveAllowPolicy) grants sqs:SendMessage to the source queue's
account. If no such grant is visible, the redrive is non-functional —
messages attempting to move to the DLQ will be silently dropped.
Verify the DLQ's RedriveAllowPolicy includes the source queue ARN under
redrivePermission: "byQueue" or redrivePermission: "allowAll".
Flag as CONFIG_GAP with MEDIUM risk. Note: "Cross-account DLQ — verify DLQ
queue policy grants SendMessage to source account."
Step 5: OK — aggregation
If no findings from Steps 1-4:
QUEUE: <queue-url>
VERDICT: OK
REASON: <queue-name> has a DLQ configured (maxReceiveCount=<N>), encryption-at-rest
enabled (<SSE-SQS|SSE-KMS>), no public queue-policy exposure, and retention
periods within recommended bounds.
RISK: LOW
REMEDIATION: None required.
Output format (per queue)
QUEUE: <queue-url or name>
VERDICT: PUBLIC_ACCESS | NO_DLQ | NO_ENCRYPTION | CONFIG_GAP | OK
REASON: <1-2 sentences citing the worst finding and step number>
RISK: CRITICAL | HIGH | MEDIUM | LOW
FINDINGS:
- [CRITICAL] <finding description (Step N)>
- [HIGH] <finding description (Step N)>
- [OK] <dimension that passed>
REMEDIATION: <specific action per finding, or "None required" if OK>
Worked example — public access with DLQ configured
QUEUE: https://sqs.us-east-1.amazonaws.com/111111111111/billing-events
VERDICT: PUBLIC_ACCESS
REASON: Queue policy Statement "OpenSend" grants sqs:SendMessage to
Principal:"*" with no restrictive condition — any AWS account can inject
messages into the billing queue (Step 1).
RISK: CRITICAL
FINDINGS:
- [CRITICAL] Principal:"*" + sqs:SendMessage with no condition (Step 1) — any account can poison the queue
- [OK] RedrivePolicy configured with maxReceiveCount=5 (Step 2)
- [OK] SSE-SQS encryption enabled (Step 3)
REMEDIATION:
1. Remove the "OpenSend" statement or add aws:SourceArn / aws:SourceAccount
to scope access to the trusted producer.
2. Back up the current queue policy before changes:
aws sqs get-queue-attributes --queue-url <url> --attribute-names Policy
--output json > /tmp/<queue>-policy-backup.json.
Edge-case handling
Edge-case catalog (SourceArn/SourceAccount strength, empty policy secure default,
DLQ with own DLQ, FIFO standard DLQ, int vs string, worst statement): references/advanced-patterns.md.
Anti-Patterns — NEVER
NEVER classify Principal: "*" with a STRONG condition (aws:SourceArn,
aws:SourceAccount) as PUBLIC_ACCESS. This is the standard S3/SNS-to-SQS
notification pattern. The condition is set by the AWS service layer and
the caller cannot forge it. Flagging it as public is a false positive that
causes unnecessary policy churn and erodes trust in the audit.
NEVER classify a queue with SqsManagedSseEnabled: true as NO_ENCRYPTION.
SSE-SQS provides AES-256-GCM encryption at rest, is FIPS-validated, and
satisfies SOC2 / PCI-DSS / HIPAA at-rest encryption requirements. It is
functionally equivalent to SSE-KMS for encryption purposes — the
difference is key management (AWS-managed vs customer-managed), not
encryption strength.
NEVER recommend maxReceiveCount: 1. A single transient failure (consumer
crash, Lambda throttle, VisibilityTimeout too short, network blip) sends
the message irretrievably to the DLQ. The minimum recommended value is 3
for standard queues, 5 for FIFO queues (where message-group blocking
makes each retry more expensive).
NEVER flag a missing Policy attribute as a security gap. The absence of
a resource-based queue policy means access is governed solely by IAM
identity-based policies — this is the SECURE default. Only flag the
PRESENCE of a permissive policy.
NEVER recommend the legacy Redrive API (deprecated 2022) for moving
messages back from the DLQ. Use aws sqs start-message-move-task --source-arn <dlq-arn> --destination-arn <source-arn> (the current
asynchronous redrive API).
NEVER assume RedrivePolicy is a native dict. It is a JSON-encoded
string in the API response. Reading policy["deadLetterTargetArn"]
directly on the unparsed string returns None / throws — producing a
false NO_DLQ verdict. Always JSON-parse the inner string first.
NEVER treat aws:SourceVpce as a STRONG condition for public-access
classification. VPC endpoints can be reachable from peered VPCs, VPN
connections, and Transit Gateway attachments. Unlike aws:SourceArn
(set by the AWS service layer), VPC endpoint identity is
network-adjacent and more easily bypassed. Treat as WEAK.
NEVER set maxReceiveCount above 1000 without explicit justification. At
a 30-second VisibilityTimeout, 1000 retries = 8+ hours of poison-pill
cycling. For FIFO queues, this means 8+ hours of message-group stall.
NEVER recommend a DLQ MessageRetentionPeriod below 4 days. Operations
teams need time to analyse and replay failed messages. The SQS minimum is
60 seconds; the maximum is 1209600 seconds (14 days). Use 14 days for
DLQs to ensure weekend and holiday coverage.
NEVER ignore the FIFO DLQ type constraint. A FIFO queue's DLQ must also be
FIFO. A standard DLQ silently fails to receive redriven messages from a
FIFO source — the poison pill stays in the source queue forever.
NEVER assume the queue policy is the complete access picture. SQS access
is governed by the INTERSECTION of IAM identity-based policies AND the
resource-based queue policy (for cross-account) or EITHER (for same-
account). A queue with no resource-based policy may still be accessible
via IAM. The audit evaluates the resource-based policy for public
exposure — it does not enumerate all IAM principals.
NEVER recommend SSE-KMS over SSE-SQS purely for "better security" without
explaining the trade-off. SSE-KMS adds per-API KMS cost (~$0.03/10k
requests + KMS key cost), potential throttle from KMS rate limits, and
latency from the KMS decrypt call. SSE-SQS is sufficient unless you need
customer-managed key control, CloudTrail decrypt logging, or key-level
grant revocation.
Pre-flight safety checks (run before any remediation CLI)
MANDATORY CONFIRMATION GATE. Before any state-changing operation
(SetQueueAttributes, RemovePermission, AddPermission, PurgeQueue,
DeleteQueue, StartMessageMoveTask), the auditor MUST emit:
CONFIRM: About to <action> on queue <url>. This affects <consequence>. Proceed? (yes/no)
Do NOT execute the CLI command until the operator confirms.
Back up the current queue policy and attributes before modification.
Queue policies are not versioned — there is no rollback without a backup.
aws sqs get-queue-attributes --queue-url <url> \
--attribute-names All --output json > /tmp/<queue>-attrs-backup-$(date +%s).json
PurgeQueue is destructive and irreversible. aws sqs purge-queue
deletes ALL messages in the queue instantly (up to the purge limit). It
cannot be scoped to specific messages. NEVER recommend PurgeQueue as a
remediation for poison-pill messages — use StartMessageMoveTask to move
them to the DLQ instead.
SetQueueAttributes replaces, not merges. Setting Policy via
SetQueueAttributes replaces the ENTIRE queue policy. If the new policy
omits a statement that a producer depends on, that producer silently
loses access. Always diff the old and new policy before applying.
For PUBLIC_ACCESS findings (CRITICAL): treat as incident-response.
An attacker may have already injected or exfiltrated messages. After
remediation, audit CloudTrail for sqs:SendMessage /
sqs:ReceiveMessage events from unexpected principals during the
exposure window. Messages that were exfiltrated should be considered
compromised — rotate any credentials or tokens that were in message
bodies.
Prefer additive changes (add a Deny statement, add a Condition) over
destructive changes (remove a statement). Additive changes are reversible
and do not risk breaking existing producers/consumers.
Remediation guidance
Per-verdict remediation steps and fix commands (PUBLIC_ACCESS, NO_DLQ,
NO_ENCRYPTION, CONFIG_GAP 4a-4d, OK): references/error-handling.md.
Recent AWS features (2024-2026)
Recent AWS features (paused queues, 14-day retention, SSE-SQS vs SSE-KMS,
StartMessageMoveTask redrive): references/advanced-patterns.md.
References (load on demand)
- Advanced patterns — Step 0 expert knowledge, edge-case catalog, recent AWS features moved from SKILL.md
- Error handling — per-verdict remediation guidance and fix commands moved from SKILL.md
Domain
AWS CloudOps / App Integration — SQS Messaging Security & Reliability.
AWS documentation
1---2name: sqs-dlq-policy-auditor3description: Audits AWS SQS queues for dead-letter-queue (DLQ) configuration gaps, public access via Principal:* queue policies, encryption-at-rest status (SSE-SQS / SSE-KMS), maxReceiveCount tuning, message-retention periods, and cross-account DLQ accessibility. Emits a deterministic verdict (NO_DLQ | PUBLIC_ACCESS | NO_ENCRYPTION | CONFIG_GAP | OK) per queue with enumerated findings and specific CLI remediation. Use when reviewing SQS queue configurations, checking for missing or misconfigured dead-letter queues, validating encryption posture, auditing queue policies for public exposure, or tuning redrive-policy parameters before production deployment.4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). No AWS CLI required for offline attribute-document classification. Live-account audits use aws sqs get-queue-attributes, aws sqs list-queues, and aws sqs get-queue-url (AWS CLI v2, SSO or key-based credentials).6metadata:7 source: https://skillmd.com/skills/jhkchan/sqs-dlq-policy-auditor8 domain: aws-cloudops9 complexity: high10 requires_llm: 'true'11 phase: '2'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: AppIntegration15 verdict_shape: NO_DLQ | PUBLIC_ACCESS | NO_ENCRYPTION | CONFIG_GAP | OK16 when_to_use: Reviewing an SQS queue configuration before production deployment, checking for a missing dead-letter queue, auditing a queue policy for public access, validating encryption-at-rest, tuning maxReceiveCount, inspecting DLQ retention, or hardening SQS posture across an account.17 activation_triggers: audit this SQS queue, is my SQS queue missing a DLQ, check SQS redrive policy, is my SQS queue public, SQS queue encryption, maxReceiveCount tuning, DLQ retention period, cross-account DLQ, poison pill SQS, harden SQS queue18 invocation_schema: 'Input: either (a) an SQS queue attribute document (Policy, RedrivePolicy, KmsMasterKeyId, SqsManagedSseEnabled, MessageRetentionPeriod, VisibilityTimeout), optionally paired with DLQ attributes, OR (b) a queue URL/ARN for live-account audit. Output: deterministic QUEUE/VERDICT/REASON/ FINDINGS/REMEDIATION block per queue, where VERDICT is one of NO_DLQ, PUBLIC_ACCESS, NO_ENCRYPTION, CONFIG_GAP, OK.'19 version: 0.1.020 author: Jacky Chan — AWS Community Builder21 keywords: SQS, dead-letter queue, DLQ, redrive policy, maxReceiveCount, queue policy, Principal:"*", public access, SSE-SQS, SSE-KMS, KmsMasterKeyId, SqsManagedSseEnabled, message retention, cross-account DLQ, FIFO queue, poison pill, RedriveAllowPolicy, VisibilityTimeout, SQS audit, queue security22 tags: sqs, app-integration, dead-letter-queue, redrive-policy, encryption, queue-policy, public-access, audit23---2425# SQS DLQ Policy Auditor2627## Mindset2829**One-line takeaway:** the verdict is always the **worst** finding across30five dimensions, and three SQS behaviours catch even experienced engineers —31`Principal: "*"` in a queue policy is usually **safe** (S3/SNS notification32pattern), `maxReceiveCount` counts **per delivery not per consumer**, and33`RedrivePolicy` is a **JSON-encoded string** that must be parsed before34classification.3536A dead-letter queue is the only safety net against poison-pill messages. A37queue without a DLQ silently retries bad messages until they expire, burning38through compute budget and starving healthy messages. Public queue policies39expose message payloads to any AWS account. Missing encryption leaves message40bodies in plaintext at rest.4142## Quick reference — verdict thresholds4344| Condition | Verdict | Risk | Rule |45|---|---|---|---|46| `Principal: "*"` + `sqs:SendMessage`/`sqs:*`/`*` + no strong condition | **PUBLIC_ACCESS** | CRITICAL | Step 1 |47| No `RedrivePolicy` attribute / missing `deadLetterTargetArn` | **NO_DLQ** | HIGH | Step 2 |48| Neither `SqsManagedSseEnabled: true` nor `KmsMasterKeyId` set | **NO_ENCRYPTION** | HIGH | Step 3 |49| `maxReceiveCount` <= 1 (too aggressive) | **CONFIG_GAP** | MEDIUM | Step 4a |50| `maxReceiveCount` > 1000 (poison-pill loop) | **CONFIG_GAP** | MEDIUM | Step 4b |51| DLQ `MessageRetentionPeriod` < 345600 (4 days) | **CONFIG_GAP** | MEDIUM | Step 4c |52| DLQ ARN in a different account + no `RedriveAllowPolicy` granting access | **CONFIG_GAP** | MEDIUM | Step 4d |53| All dimensions pass | **OK** | LOW | Step 5 |5455See the ordered steps below for edge cases (Principal:"*" with SourceArn,56FIFO DLQ constraints, VisibilityTimeout interaction).5758## Pre-flight: queue metadata gate5960Before evaluating the queue policy and redrive configuration, classify the61queue itself. Several attributes short-circuit or modify the audit.6263**Multi-queue / account-wide sweep note (pagination):** `aws sqs list-queues`64returns up to 1000 queue URLs per page. Use `--next-token` (from the prior65`NextToken`) to page through all queues; iterating only the first page66silently misses queues. For each URL, `aws sqs get-queue-attributes67--queue-url <url> --attribute-names All` returns all attributes in one call68(no pagination needed for attributes).6970| Attribute | Value | Effect on audit |71|---|---|---|72| `FifoQueue` | `true` | **FIFO queue.** DLQ must also be FIFO. maxReceiveCount tuning is MORE critical — a poison pill in a message group blocks the entire group until moved to DLQ. |73| `FifoQueue` | `false` / absent | **Standard queue.** Normal audit. |74| `ContentBasedDeduplication` | `true` (FIFO) | Deduplication runs before receive count — a retried message with the same dedup ID does NOT increment the counter. Poison pills persist longer than expected. |75| `Policy` | absent / empty | **No resource-based policy.** Only IAM identity-based policies govern access. This is the SECURE default — do not flag as a gap. |76| `KmsMasterKeyId` | set | **SSE-KMS encryption.** Customer-managed or AWS-managed KMS key. Encryption is satisfied. |77| `SqsManagedSseEnabled` | `true` | **SSE-SQS encryption.** Amazon SQS-managed encryption (free, FIPS-compliant). Encryption is satisfied. |7879**If the queue attribute document is malformed** (the `Policy` field is not80valid JSON, or `RedrivePolicy` is not valid JSON when present), output:8182```text83QUEUE: <queue-url>84VERDICT: ERROR85REASON: Queue attribute document is malformed — <field> is not valid JSON.86REMEDIATION: Re-fetch with `aws sqs get-queue-attributes --queue-url <url> --attribute-names All --output json` and re-audit.87```8889**RedrivePolicy is a JSON-encoded string, not a native attribute.**90`aws sqs get-queue-attributes` returns `RedrivePolicy` as a91JSON-encoded **string** (double-encoded in the CLI JSON output). You MUST92parse the inner JSON before reading `deadLetterTargetArn` and93`maxReceiveCount`. A classification that reads the raw string as a dict94produces false NO_DLQ verdicts — the field looks absent because it was never95parsed.9697## Process — Classification logic (apply in order, aggregate worst)9899### Step 0: Expert knowledge — non-obvious SQS behaviours that change classification100101Full catalog (Principal:"*" usually safe, per-delivery counting, FIFO group102blocking, SSE-SQS, RedriveAllowPolicy, VT window, ESM, v2 API, casing): [references/advanced-patterns.md](references/advanced-patterns.md).103104### Step 1: Public access via queue policy (PUBLIC_ACCESS)105106For each `Effect: Allow` statement in the queue policy, classify the107principal scope:108109- **WILDCARD_PRINCIPAL** — `Principal: "*"`, `Principal: {"AWS": "*"}`, or110 any construct resolving to all AWS principals.111112- **NAMED_PRINCIPAL** — `Principal: {"AWS": "arn:aws:iam::ACCOUNT:role/..."}`113 or `Principal: {"Service": "s3.amazonaws.com"}`.114115A WILDCARD_PRINCIPAL statement is classified by its **condition strength**:116117**STRONG conditions (NOT public — access is genuinely scoped):**118- `aws:SourceArn` (`ArnEquals` / `ArnLike`) — request must originate from119 the named resource (S3 bucket, SNS topic). This is the standard S3/SNS-120 to-SQS pattern. The caller cannot forge this; it is set by the AWS121 service layer.122- `aws:SourceAccount` (`StringEquals`) — request must originate from the123 named account.124- `aws:SourceAws` (deprecated alias of SourceAccount).125126**WEAK / NO conditions (PUBLIC — flag as PUBLIC_ACCESS):**127- No `Condition` block at all.128- `aws:SourceIp` / `aws:SourceIp` containing `0.0.0.0/0` — IP-based129 restrictions are bypassable; `0.0.0.0/0` is the entire internet.130- `aws:SourceVpce` / `aws:SourceVpc` — VPC-scoped but the VPC endpoint is131 network-reachable from peered connections; treat as WEAK for public-132 exposure classification.133- `aws:Referer`, `aws:UserAgent` — trivially forgeable by any HTTP client.134135**Action sensitivity for WILDCARD_PRINCIPAL with weak/no condition:**136137| Action | Severity | Why |138|---|---|---|139| `sqs:SendMessage` | **CRITICAL** | Any account can inject messages — data poisoning, queue flooding, cost amplification. |140| `sqs:ReceiveMessage` | **CRITICAL** | Any account can drain the queue — silent data exfiltration of message payloads. |141| `sqs:DeleteMessage` | **CRITICAL** | Any account can delete messages — silent data loss. |142| `sqs:*` / `*` | **CRITICAL** | Full queue control — inject, drain, delete, reconfigure. |143| `sqs:GetQueueAttributes` / `sqs:GetQueueUrl` | **MEDIUM** | Metadata disclosure only (queue config, approximate message counts). Not PUBLIC_ACCESS verdict — note as advisory. |144145If any WILDCARD_PRINCIPAL statement with a sensitive action (SendMessage,146ReceiveMessage, DeleteMessage, sqs:*, *) and a WEAK/NO condition is found,147the queue verdict is **PUBLIC_ACCESS** with **CRITICAL** risk.148149### Step 2: Dead-letter queue presence (NO_DLQ)150151Evaluate the `RedrivePolicy` attribute (after JSON-parsing the string):152153- **Absent / empty / malformed** → **NO_DLQ**. No dead-letter queue is154 configured. Poison-pill messages retry until `MessageRetentionPeriod`155 expires (default 4 days). Every retry is a billable API call. With a high156 `maxReceiveCount` (if somehow set without a DLQ — configuration drift),157 the retry storm can last days.158159- **Present but `deadLetterTargetArn` missing** → **NO_DLQ**. The policy160 JSON exists but the DLQ target is absent — the redrive is non-functional.161162- **Present with `deadLetterTargetArn`** → proceed to Step 4d (DLQ163 accessibility sub-check).164165**FIFO queue special case:** if `FifoQueue: true` and the `deadLetterTargetArn`166points to a standard (non-FIFO) queue, the redrive is INVALID — SQS silently167rejects messages to a standard DLQ from a FIFO source. Flag as NO_DLQ with168note: "DLQ ARN points to a standard queue — FIFO source requires a FIFO DLQ."169170### Step 3: Encryption-at-rest (NO_ENCRYPTION)171172Evaluate encryption from two attributes:173174- **`SqsManagedSseEnabled: true`** → SSE-SQS is active. Encryption is175 satisfied. This is the free, AWS-managed option (AES-256-GCM, FIPS-176 validated). Do NOT flag.177178- **`KmsMasterKeyId` set to a key ARN / key ID / alias** → SSE-KMS is179 active. Encryption is satisfied. Note whether the key is AWS-managed180 (`alias/aws/sqs`) or customer-managed (for cost/rotation auditing — route181 to kms-key-policy-auditor for the key policy).182183- **Neither set** → **NO_ENCRYPTION**. Message bodies are stored in184 plaintext at rest. Messages are always encrypted in transit (TLS), but185 the at-rest storage is unencrypted. Flag as HIGH risk.186187### Step 4: Configuration gaps (CONFIG_GAP sub-checks)188189If no higher-severity verdict was triggered (PUBLIC_ACCESS, NO_DLQ,190NO_ENCRYPTION), evaluate the following sub-checks. Each finding is191enumerated; any non-empty finding set produces a **CONFIG_GAP** verdict.192193#### Step 4a: maxReceiveCount too low194195If `maxReceiveCount` (from the parsed RedrivePolicy) is <= 1:196197- **maxReceiveCount: 1** → any transient failure (consumer crash, network198 blip, Lambda throttle, VisibilityTimeout too short) sends the message199 straight to the DLQ on the FIRST delivery attempt. This is almost always200 a misconfiguration — the message never gets a second chance. High false-201 positive DLQ rate.202203- **maxReceiveCount: 2-3** with Lambda event source mapping → advisory. The204 Lambda service's batch window adds delay between retries, so 2-3205 invocations may be insufficient for transient downstream failures.206207Flag as CONFIG_GAP with MEDIUM risk. Recommended: set to 5-10 for standard208queues, 5-15 for FIFO queues (message-group blocking makes retries cheaper).209210#### Step 4b: maxReceiveCount too high211212If `maxReceiveCount` > 1000:213214- The message retries up to 1000+ times before reaching the DLQ. At a215 VisibilityTimeout of 30s, that is ~8+ hours of retry cycles. Poison-pill216 messages burn compute budget and starve healthy messages in the queue.217 For FIFO queues, the message group is stalled for the entire duration.218219Flag as CONFIG_GAP with MEDIUM risk. Recommended: 5-100 for standard queues,2205-20 for FIFO queues.221222#### Step 4c: DLQ message-retention period too short223224If the DLQ's `MessageRetentionPeriod` < 345600 (4 days):225226- Failed messages expire from the DLQ before operations teams can analyse227 and replay them. The DLQ is useless as a diagnostic tool if messages228 vanish before anyone looks. The default retention (4 days / 345600s) is229 already marginal for weekend coverage.230231Flag as CONFIG_GAP with MEDIUM risk. Recommended: 1209600 (14 days, the232maximum) for DLQs to ensure weekend/holiday coverage.233234If DLQ attributes are not provided in the input, note: "DLQ retention period235not provided — fetch with `aws sqs get-queue-attributes --queue-url <dlq-url>236--attribute-names MessageRetentionPeriod` to verify."237238#### Step 4d: Cross-account DLQ accessibility239240If the `deadLetterTargetArn` in the RedrivePolicy points to a queue in a241different AWS account (12-digit account ID differs from the source queue's242account):243244- The DLQ is cross-account. SQS supports this IF the DLQ's queue policy (or245 `RedriveAllowPolicy`) grants `sqs:SendMessage` to the source queue's246 account. If no such grant is visible, the redrive is non-functional —247 messages attempting to move to the DLQ will be silently dropped.248249- Verify the DLQ's `RedriveAllowPolicy` includes the source queue ARN under250 `redrivePermission: "byQueue"` or `redrivePermission: "allowAll"`.251252Flag as CONFIG_GAP with MEDIUM risk. Note: "Cross-account DLQ — verify DLQ253queue policy grants SendMessage to source account."254255### Step 5: OK — aggregation256257If no findings from Steps 1-4:258259```text260QUEUE: <queue-url>261VERDICT: OK262REASON: <queue-name> has a DLQ configured (maxReceiveCount=<N>), encryption-at-rest263 enabled (<SSE-SQS|SSE-KMS>), no public queue-policy exposure, and retention264 periods within recommended bounds.265RISK: LOW266REMEDIATION: None required.267```268269## Output format (per queue)270271```text272QUEUE: <queue-url or name>273VERDICT: PUBLIC_ACCESS | NO_DLQ | NO_ENCRYPTION | CONFIG_GAP | OK274REASON: <1-2 sentences citing the worst finding and step number>275RISK: CRITICAL | HIGH | MEDIUM | LOW276FINDINGS:277 - [CRITICAL] <finding description (Step N)>278 - [HIGH] <finding description (Step N)>279 - [OK] <dimension that passed>280REMEDIATION: <specific action per finding, or "None required" if OK>281```282283### Worked example — public access with DLQ configured284285```text286QUEUE: https://sqs.us-east-1.amazonaws.com/111111111111/billing-events287VERDICT: PUBLIC_ACCESS288REASON: Queue policy Statement "OpenSend" grants sqs:SendMessage to289 Principal:"*" with no restrictive condition — any AWS account can inject290 messages into the billing queue (Step 1).291RISK: CRITICAL292FINDINGS:293 - [CRITICAL] Principal:"*" + sqs:SendMessage with no condition (Step 1) — any account can poison the queue294 - [OK] RedrivePolicy configured with maxReceiveCount=5 (Step 2)295 - [OK] SSE-SQS encryption enabled (Step 3)296REMEDIATION:297 1. Remove the "OpenSend" statement or add aws:SourceArn / aws:SourceAccount298 to scope access to the trusted producer.299 2. Back up the current queue policy before changes:300 aws sqs get-queue-attributes --queue-url <url> --attribute-names Policy301 --output json > /tmp/<queue>-policy-backup.json.302```303304## Edge-case handling305306Edge-case catalog (SourceArn/SourceAccount strength, empty policy secure default,307DLQ with own DLQ, FIFO standard DLQ, int vs string, worst statement): [references/advanced-patterns.md](references/advanced-patterns.md).308309## Anti-Patterns — NEVER310311- NEVER classify `Principal: "*"` with a STRONG condition (`aws:SourceArn`,312 `aws:SourceAccount`) as PUBLIC_ACCESS. This is the standard S3/SNS-to-SQS313 notification pattern. The condition is set by the AWS service layer and314 the caller cannot forge it. Flagging it as public is a false positive that315 causes unnecessary policy churn and erodes trust in the audit.316317- NEVER classify a queue with `SqsManagedSseEnabled: true` as NO_ENCRYPTION.318 SSE-SQS provides AES-256-GCM encryption at rest, is FIPS-validated, and319 satisfies SOC2 / PCI-DSS / HIPAA at-rest encryption requirements. It is320 functionally equivalent to SSE-KMS for encryption purposes — the321 difference is key management (AWS-managed vs customer-managed), not322 encryption strength.323324- NEVER recommend `maxReceiveCount: 1`. A single transient failure (consumer325 crash, Lambda throttle, VisibilityTimeout too short, network blip) sends326 the message irretrievably to the DLQ. The minimum recommended value is 3327 for standard queues, 5 for FIFO queues (where message-group blocking328 makes each retry more expensive).329330- NEVER flag a missing `Policy` attribute as a security gap. The absence of331 a resource-based queue policy means access is governed solely by IAM332 identity-based policies — this is the SECURE default. Only flag the333 PRESENCE of a permissive policy.334335- NEVER recommend the legacy `Redrive` API (deprecated 2022) for moving336 messages back from the DLQ. Use `aws sqs start-message-move-task337 --source-arn <dlq-arn> --destination-arn <source-arn>` (the current338 asynchronous redrive API).339340- NEVER assume `RedrivePolicy` is a native dict. It is a JSON-encoded341 string in the API response. Reading `policy["deadLetterTargetArn"]`342 directly on the unparsed string returns `None` / throws — producing a343 false NO_DLQ verdict. Always JSON-parse the inner string first.344345- NEVER treat `aws:SourceVpce` as a STRONG condition for public-access346 classification. VPC endpoints can be reachable from peered VPCs, VPN347 connections, and Transit Gateway attachments. Unlike `aws:SourceArn`348 (set by the AWS service layer), VPC endpoint identity is349 network-adjacent and more easily bypassed. Treat as WEAK.350351- NEVER set `maxReceiveCount` above 1000 without explicit justification. At352 a 30-second VisibilityTimeout, 1000 retries = 8+ hours of poison-pill353 cycling. For FIFO queues, this means 8+ hours of message-group stall.354355- NEVER recommend a DLQ `MessageRetentionPeriod` below 4 days. Operations356 teams need time to analyse and replay failed messages. The SQS minimum is357 60 seconds; the maximum is 1209600 seconds (14 days). Use 14 days for358 DLQs to ensure weekend and holiday coverage.359360- NEVER ignore the FIFO DLQ type constraint. A FIFO queue's DLQ must also be361 FIFO. A standard DLQ silently fails to receive redriven messages from a362 FIFO source — the poison pill stays in the source queue forever.363364- NEVER assume the queue policy is the complete access picture. SQS access365 is governed by the INTERSECTION of IAM identity-based policies AND the366 resource-based queue policy (for cross-account) or EITHER (for same-367 account). A queue with no resource-based policy may still be accessible368 via IAM. The audit evaluates the resource-based policy for public369 exposure — it does not enumerate all IAM principals.370371- NEVER recommend SSE-KMS over SSE-SQS purely for "better security" without372 explaining the trade-off. SSE-KMS adds per-API KMS cost (~$0.03/10k373 requests + KMS key cost), potential throttle from KMS rate limits, and374 latency from the KMS decrypt call. SSE-SQS is sufficient unless you need375 customer-managed key control, CloudTrail decrypt logging, or key-level376 grant revocation.377378## Pre-flight safety checks (run before any remediation CLI)379380- **MANDATORY CONFIRMATION GATE.** Before any state-changing operation381 (SetQueueAttributes, RemovePermission, AddPermission, PurgeQueue,382 DeleteQueue, StartMessageMoveTask), the auditor MUST emit:383 `CONFIRM: About to <action> on queue <url>. This affects <consequence>.384 Proceed? (yes/no)`385 Do NOT execute the CLI command until the operator confirms.386387- **Back up the current queue policy and attributes before modification.**388 Queue policies are not versioned — there is no rollback without a backup.389 ```bash390 aws sqs get-queue-attributes --queue-url <url> \391 --attribute-names All --output json > /tmp/<queue>-attrs-backup-$(date +%s).json392 ```393394- **PurgeQueue is destructive and irreversible.** `aws sqs purge-queue`395 deletes ALL messages in the queue instantly (up to the purge limit). It396 cannot be scoped to specific messages. NEVER recommend PurgeQueue as a397 remediation for poison-pill messages — use StartMessageMoveTask to move398 them to the DLQ instead.399400- **SetQueueAttributes replaces, not merges.** Setting `Policy` via401 `SetQueueAttributes` replaces the ENTIRE queue policy. If the new policy402 omits a statement that a producer depends on, that producer silently403 loses access. Always diff the old and new policy before applying.404405- **For PUBLIC_ACCESS findings (CRITICAL):** treat as incident-response.406 An attacker may have already injected or exfiltrated messages. After407 remediation, audit CloudTrail for `sqs:SendMessage` /408 `sqs:ReceiveMessage` events from unexpected principals during the409 exposure window. Messages that were exfiltrated should be considered410 compromised — rotate any credentials or tokens that were in message411 bodies.412413- Prefer additive changes (add a Deny statement, add a Condition) over414 destructive changes (remove a statement). Additive changes are reversible415 and do not risk breaking existing producers/consumers.416417## Remediation guidance418419Per-verdict remediation steps and fix commands (PUBLIC_ACCESS, NO_DLQ,420NO_ENCRYPTION, CONFIG_GAP 4a-4d, OK): [references/error-handling.md](references/error-handling.md).421422## Recent AWS features (2024-2026)423424Recent AWS features (paused queues, 14-day retention, SSE-SQS vs SSE-KMS,425StartMessageMoveTask redrive): [references/advanced-patterns.md](references/advanced-patterns.md).426427## References (load on demand)428429- [Advanced patterns](references/advanced-patterns.md) — Step 0 expert knowledge, edge-case catalog, recent AWS features moved from SKILL.md430- [Error handling](references/error-handling.md) — per-verdict remediation guidance and fix commands moved from SKILL.md431432## Domain433434AWS CloudOps / App Integration — SQS Messaging Security & Reliability.435436## AWS documentation437438- **Amazon SQS Developer Guide** — https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html439- **SQS Security** — https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-security-best-practices.html440- **SQS API Reference** — https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/441- **SQS CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/sqs/442- **Dead-letter queue redrive** — https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-dead-letter-queue-redrive.html