{"record":{"id":"10da4741c1ef545c","repo":"dutchcoders/transfer.sh","slug":"gopenpgp-wrong-password-in-symmetric-decryption","errorCode":null,"errorMessage":"gopenpgp: wrong password in symmetric decryption","messagePattern":"gopenpgp: wrong password in symmetric decryption","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/handlers.go","lineNumber":133,"sourceCode":"\n\treturn decrypt(reader, []byte(password))\n}\n\nfunc decrypt(ciphertext io.ReadCloser, password []byte) (plaintext io.ReadCloser, err error) {\n\tunarmored, err := armor.Decode(ciphertext)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tfirstTimeCalled := true\n\tvar prompt = func(keys []openpgp.Key, symmetric bool) ([]byte, error) {\n\t\tif firstTimeCalled {\n\t\t\tfirstTimeCalled = false\n\t\t\treturn password, nil\n\t\t}\n\t\t// Re-prompt still occurs if SKESK pasrsing fails (i.e. when decrypted cipher algo is invalid).\n\t\t// For most (but not all) cases, inputting a wrong passwords is expected to trigger this error.\n\t\treturn nil, errors.New(\"gopenpgp: wrong password in symmetric decryption\")\n\t}\n\n\tconfig := &packet.Config{\n\t\tDefaultCipher: packet.CipherAES256,\n\t}\n\n\tvar emptyKeyRing openpgp.EntityList\n\tmd, err := openpgp.ReadMessage(unarmored.Body, emptyKeyRing, prompt, config)\n\tif err != nil {\n\t\t// Parsing errors when reading the message are most likely caused by incorrect password, but we cannot know for sure\n\t\treturn\n\t}\n\n\tplaintext = io.NopCloser(md.UnverifiedBody)\n\n\treturn\n}\n","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/dutchcoders/transfer.sh/blob/c37bfd95797fd6da8a6da53fc13d191994b3f687/server/handlers.go#L115-L151","documentation":"This error is produced by the password-prompt callback in server/handlers.go during symmetric (passphrase-protected) OpenPGP decryption. gopenpgp invokes the callback again when SKESK parsing fails (e.g. the decrypted cipher algorithm is invalid), which for most inputs means the supplied passphrase was wrong. The server returns this error instead of re-prompting, so the uploaded encrypted file cannot be decrypted.","triggerScenarios":"A client uploads a file encrypted with a symmetric passphrase, then GETs it with a --password that does not match the encryption passphrase; the second callback invocation (firstTimeCalled already false) returns this error.","commonSituations":"User typos the passphrase on download, passphrase contains characters mangled by shell quoting or URL encoding, file was re-encrypted with a different passphrase, or an actually corrupted/invalid encrypted payload triggers the same re-prompt path.","solutions":["Retry the download supplying the exact passphrase used at upload time.","Quote the passphrase correctly in the shell and URL-encode it in the URL/Authorization header to avoid character mangling.","Verify the downloaded artifact is the original encrypted file and not corrupted (compare checksums).","If payloads are legitimate but fail, check the gopenpgp version for SKESK/cipher-algo compatibility issues and update dependencies."],"exampleFix":"// before\ncurl -OJ --user 'x:wrongpass' https://host/token/filename\n// after\ncurl -OJ --user 'x:correct-passphrase' https://host/token/filename","handlingStrategy":"validation","validationCode":"# verify the passphrase decrypts before sharing/uploading:\necho test | gpg --symmetric --cipher-algo AES256 -o /tmp/t.gpg && \\\n  gpg --decrypt --passphrase '$PASSPHRASE' /tmp/t.gpg >/dev/null || echo \"bad passphrase\"","typeGuard":null,"tryCatchPattern":"out, err := downloadWithPassword(token, file, pass)\nif err != nil && strings.Contains(err.Error(), \"wrong password\") {\n\t// prompt user again for the correct passphrase\n\treturn retryWithNewPassword()\n}","preventionTips":["Store the upload passphrase in a password manager, not in chat history.","Single-quote passphrases in shells and URL-encode them in requests.","Test decryption immediately after upload, before distributing the link."],"tags":["gopenpgp","decryption","password","openpgp"],"backgroundTag":"wrong-passphrase","analyzedSha":"c37bfd95797fd6da8a6da53fc13d191994b3f687","analyzedAt":"2026-09-05T10:21:07.548Z","contentChangedAt":"2026-09-05T10:21:07.548Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}