No confirmation prompt on any destructive operation #39
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the 1.0 security survey.
Threat
There is no interactive confirmation anywhere in the tool. Searching non-test code for
are you sure,[y/N], andbufio.NewReader(os.Stdin)returns zero hits.secret rm(internal/cli/secrets.go:180-205,RemoveSecret:651) deletes a secret and all its versions with no prompt and no--forceflag at all.secret vault remove(internal/cli/vault.go:144-174,RemoveVault:579) requires--forceonly when the vault is non-empty and refuses to remove the last vault, but never prompts.secret unlocker remove(internal/cli/unlockers.go:257-289) has a--forceflag, no prompt. Removing the last unlocker without the mnemonic makes the vault permanently unrecoverable — the README says so in capitals.The README currently documents this as deliberate, comparing it to Unix
rm. That comparison does not hold:rmdeletes a file the user can often restore from backup, whereas this deletes the only copy of key material that by design exists nowhere else. And unlikerm, there is no-i, no trash, and no undo.This compounds the unvalidated-name bug (#33): today
secret rm ..destroys the entire vault with a single keystroke sequence and no opportunity to reconsider.Definition of done
secret rm,secret version rm,secret vault remove,secret unlocker remove.unlocker removewhen it is the last unlocker, the prompt states plainly that the vault becomes unrecoverable without the mnemonic.--force/-fskips the prompt on every one of these commands, so existing scripted use keeps working with one flag added.--force. This is the part most likely to be got wrong, and getting it wrong breaks CI pipelines or, worse, makes them destructive.--forcebypasses the prompt, and non-TTY without--forcefails cleanly without blocking.make checkgreen.TODO.mdupdated in the same commit.Implementation requirements
secret rm foo | tee logwould then refuse or hang despite a perfectly interactive user.[y/N]means bare Enter cancels.--forcesemantics onvault removeandunlocker removecurrently mean "override a safety check", and this adds "skip the prompt" to the same flag. Make sure the combined behavior is coherent and documented, and that--forceon a last-unlocker removal still does the genuinely dangerous thing the user asked for...outright whether or not a prompt exists; a prompt that asks "really delete..?" is not a fix.