Skip to content

fix(purchases): redact idempotency token in EC2 RI re-drive skip log #656

Description

@cristim

Summary

The EC2 RI idempotency-guard skip-purchase log emits the raw caller-supplied idempotency token, the same defense-in-depth leak CodeRabbit flagged on PR #652 for the five other AWS executors (RDS, ElastiCache, MemoryDB, OpenSearch, Redshift). The EC2 path predates that PR (it came in with #636) and was therefore out of scope for #652, so it still logs the token verbatim.

Current behaviour

providers/aws/services/ec2/client.go:133:

log.Printf("EC2 RI for idempotency token %s already exists (%s); skipping purchase (issue #636 re-drive)", opts.IdempotencyToken, existingID)

The full idempotency token (a stable per-execution SHA-256 hex identifier derived from execution_id:rec_index) is written to persistent logs on every re-drive of an already-purchased EC2 RI.

Steps to verify the gap

  1. Trigger an EC2 RI purchase, then re-drive the same execution so the idempotency guard short-circuits.
  2. Inspect the executor logs: the full 64-char token appears verbatim.

Expected behaviour

The log should emit a redacted form, consistent with the other five AWS executors after #652.

Proposed fix

Wrap the token with the existing common.MaskToken helper (added in PR #652, pkg/common/tokens.go):

log.Printf("EC2 RI for idempotency token %s already exists (%s); skipping purchase (issue #636 re-drive)", common.MaskToken(opts.IdempotencyToken), existingID)

providers/aws/services/ec2 already imports github.com/LeanerCloud/CUDly/pkg/common, so no new import is needed. One-line change plus the helper is already test-covered.

References

Severity

Low - it's a stable derived identifier, not a credential, but it is a defense-in-depth log-hygiene gap and should match the treatment applied to the sibling executors.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions