Skip to content

secretsmanager: DeleteSecret always deletes immediately, so the recovery window, DeletionDate and RestoreSecret do not exist #953

Closed

Description

@scttfrdmn

Summary

DeleteSecret destroys a secret immediately, reads neither of the two parameters that decide whether it should, and omits the response member that tells a caller what happened. AWS's default is a 30-day recovery window during which the secret still exists and is restorable; substrate's only behaviour is the one AWS reserves for ForceDeleteWithoutRecovery: true. So substrate implements the dangerous variant as the default, and docs/services.md's operations table claims "Supports ForceDeleteWithoutRecovery" for a parameter nothing decodes.

Substrate's handler (emulator/secretsmanager_plugin.go:454-500) decodes only SecretId, deletes the record, the version payload and the index entry, and answers {"ARN", "Name"}.

What AWS publishes

API_DeleteSecret, opening paragraph, verbatim:

"Deletes a secret and all of its versions. You can specify a recovery window during which you can restore the secret. The minimum recovery window is 7 days. The default recovery window is 30 days. Secrets Manager attaches a DeletionDate stamp to the secret that specifies the end of the recovery window. At the end of the recovery window, Secrets Manager deletes the secret permanently."

"At any time before recovery window ends, you can use RestoreSecret to remove the DeletionDate and cancel the deletion of the secret."

"When a secret is scheduled for deletion, you cannot retrieve the secret value. You must first cancel the deletion with RestoreSecret and then you can retrieve the secret."

Request parameters, both Required: No:

  • RecoveryWindowInDays — "The number of days from 7 to 30 that Secrets Manager waits before permanently deleting the secret. You can't use both this parameter and ForceDeleteWithoutRecovery in the same call. If you don't use either, then by default Secrets Manager uses a 30 day recovery window." Type: Long.
  • ForceDeleteWithoutRecovery — "Specifies whether to delete the secret without any recovery window. You can't use both this parameter and RecoveryWindowInDays in the same call…" and, separately: "If you forcibly delete an already deleted or nonexistent secret, the operation does not return ResourceNotFoundException."

Response Syntax — three members, one of which substrate omits:

{
   "ARN": "string",
   "DeletionDate": number,
   "Name": "string"
}

DeletionDate — "The date and time after which this secret Secrets Manager can permanently delete this secret, and it can no longer be restored. This value is the date and time of the delete request plus the number of days in RecoveryWindowInDays." Type: Timestamp.

AWS's own sample returns "DeletionDate":1.524085349095E9.

Why this is in scope

A recovery window is a state transition observable through an API call, driven by a clock — the same shape as a snapshot reported pending until it reaches completed, which CLAUDE.md names as in scope explicitly. Substrate has a TimeController, and the plugin already holds one, so DeletionDate is tc.Now() plus the window and the transition is assertable without wall-clock dependence. Nothing here requires modelling the background deletion task — AWS itself declines to guarantee its timing ("There is no guarantee of a specific time after the recovery window for the permanent delete to occur"), so the observable contract is the DeletionDate stamp and the refusals it causes, not the moment the bytes go away.

What is missing, and what depends on it

Six behaviours, each observable:

  1. DeletionDate on the response, and DeletedDate on DescribeSecret — a member fix(secretsmanager): ResourceNotFoundException is 400, not 404, and DescribeSecret emits members AWS omits #930 documented as absent-because-unmodelled and which AWS states "If it is not scheduled for deletion, this field is omitted". That per-member sentence has nothing to be true about until deletion can be scheduled.
  2. GetSecretValue on a scheduled secret must be refused, per "you cannot retrieve the secret value" — InvalidRequestException/400, whose first published cause is "The secret is scheduled for deletion." Today GetSecretValue answers ResourceNotFoundException/400 because the record is gone, so the two conditions are indistinguishable to a caller.
  3. RestoreSecret is not implemented at all. It is one of the twenty-three operations AWS publishes and the only way to cancel a deletion; today the name falls to UnknownOperationException. A consumer's "oops, restore it" path cannot be tested.
  4. RecoveryWindowInDays outside 7–30 must be refused (InvalidParameterException/400), and supplying it together with ForceDeleteWithoutRecovery must be refused — AWS states the mutual exclusion twice, once under each parameter.
  5. ForceDeleteWithoutRecovery on an absent secret must answer 200, not ResourceNotFoundException — the one place AWS explicitly suspends the code fix(secretsmanager): ResourceNotFoundException is 400, not 404, and DescribeSecret emits members AWS omits #930 has just corrected the status of. Substrate answers ResourceNotFoundException there today.
  6. ListSecrets must still report a scheduled secret, since it exists until the window ends. Today it does not, because the index entry is removed.

Also: the docs table is wrong

docs/services.md's Secrets Manager operations table reads | DeleteSecret | Supports ForceDeleteWithoutRecovery |. Nothing decodes that parameter — the handler's input struct has one field, SecretId. The row should be corrected whether or not the rest of this issue is taken, because it tells a reader substrate honours a parameter it discards, in the direction that loses data.

Acceptance criteria

  • DeleteSecret reads RecoveryWindowInDays and ForceDeleteWithoutRecovery, defaults to a 30-day window, refuses a window outside 7–30 and refuses both parameters in one call.
  • Without force, the secret is marked rather than removed: DeletionDate is stamped off the TimeController and returned, DescribeSecret reports DeletedDate, and ListSecrets still reports the secret.
  • GetSecretValue on a scheduled secret answers InvalidRequestException/400 naming the scheduled-for-deletion cause — distinguishable from ResourceNotFoundException.
  • RestoreSecret is implemented: it clears DeletionDate and GetSecretValue succeeds again afterwards.
  • With ForceDeleteWithoutRecovery: true, the record is removed as today, and a forced delete of an absent secret answers 200 rather than ResourceNotFoundException, per AWS's explicit sentence.
  • The permanent deletion at the end of the window is either driven by the simulated clock or recorded as deliberately unmodelled with AWS's "no guarantee of a specific time" sentence as the reason — one or the other, stated.
  • Tests over the wire for each transition, asserting DeletedDate's presence and absence on raw bytes, per fix(secretsmanager): ResourceNotFoundException is 400, not 404, and DescribeSecret emits members AWS omits #930's precedent.
  • docs/services.md's DeleteSecret row is corrected, and the section records which of these are AWS's statements and which are substrate's readings; CHANGELOG.md states the compatibility break — a DeleteSecret that removed the record now schedules it, and a caller must pass ForceDeleteWithoutRecovery to get the old behaviour.

Provenance

Every quotation is verbatim from API_DeleteSecret, fetched for this issue. The InvalidRequestException cause list is published identically on API_DeleteSecret and API_RotateSecret.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions