Repository navigation
Description
Problem Description
The devcontainer keyring rejects the correct password after a container start. This occurred three times (the last on 2026-11-05 and 2026-11-09). Each time, every credential in the keyring became unavailable.
The cause is in two parts:
devops devcontainer post-startasks for the keyring password on the VS Code lifecycle terminal. That terminal sends each key two times. post-start gives the doubled password tognome-keyring-daemon --replace --unlock, and the daemon rejects it. The output says "Wrong password" at each start.- gnome-keyring keeps the last password that
--unlockrejected (gkm_wrap_layer_mark_login_unlock_failure,daemon/login/gkd-login.c). When a client then asks for a secret, the daemon opens the GUI prompt "Unlock Login Keyring" (gcr-prompter), because the bus and the daemon getDISPLAYandWAYLAND_DISPLAY. When the user types the correct password there,fix_login_keyring_if_unlock_failed(pkcs11/wrap-layer/gkm-wrap-prompt.c) changes the master password to the rejected one and saves the file. It shows no message. Upstream expects--unlockto get the login password from PAM, so it treats the rejected password as the new login password.
After this, the correct password does not open the keyring. The doubled password does.
Reproduction Steps
- Start the devcontainer in VS Code. At the post-start prompt, type the correct keyring password. The output says "Wrong password".
- Run a command that reads a secret, for example
gh auth token. The GUI prompt "Unlock Login Keyring" opens. Type the correct password there. - Restart the container, and run
devops devcontainer unlock-keyringin a terminal with the correct password. The output says "Wrong password".
Expected vs Actual Behavior
Expected: the keyring opens with the password that the user set. A wrong password does not change the keyring password.
Actual: the keyring password changes to the doubled post-start input, and the user gets no message.
Environment Diagnostics
- gnome-keyring 51.1-3 (Debian sid), gcr-prompter from the image.
- VS Code Dev Containers with rootless Podman on WSL2. VS Code sets
DISPLAYandWAYLAND_DISPLAYin the container. _start_session_busand_unlock_keyringinsrc/devops_cli/commands/devcontainer.pypassDISPLAYandWAYLAND_DISPLAYtodbus-daemonandgnome-keyring-daemon.
Logs, Traces, or Terminal Output
Timeline of 2026-11-09 (UTC):
- 15:01:33: post-start starts the bus. The post-start unlock says "Wrong password".
- 15:02:28: gnome-keyring saves
login.keyring. A locked collection cannot save, so the GUI prompt had opened it. - 15:03:12:
devops devcontainer unlock-keyringin a terminal says "Wrong password" for the correct password. - 15:03:40: a new gcr-prompter opens. It cannot be closed.
An offline check of the two lost keyring files tried 5,355 changes of the correct password. Only "every character doubled" opened them, for both files (2026-11-05 and 2026-11-09). A sandbox test showed that the post-start lock check reads the state correctly, so the post-start "Wrong password" is real. After ChangeWithMasterPassword from the doubled password to the correct one, the keyring opened again with all items.
On a bus with no display, a client unlock request is dismissed at once (0.0 s), and the collection stays locked. So no client hangs when the GUI prompt cannot open.
Proposed fix
- Start
dbus-daemonandgnome-keyring-daemonwithoutDISPLAYandWAYLAND_DISPLAY. No GUI prompt can open, so gnome-keyring never changes the password to a rejected one. The terminal prompt of the shell hook stays the only way to unlock. - Remove the post-start password prompt, because the lifecycle terminal doubles each key. The first interactive terminal asks for the password (the existing shell hook).
- After each successful unlock, copy
login.keyringto a backup folder and keep the last copies, so a keyring that a future fault makes unreadable can be restored. The wrong-password error names the folder.
Related: #2340 (earlier search for the cause), #2390 (the reset remedy in the error).
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Proposed design
Problem statement
The devcontainer keyring rejects the correct password after a container start. The VS Code lifecycle terminal doubles each key, so post-start gives gnome-keyring a doubled password and the daemon rejects it. The daemon keeps the rejected password. The GUI prompt then opens because DISPLAY and WAYLAND_DISPLAY reach the bus and the daemon. When the user types the correct password there, gnome-keyring changes the keyring password to the rejected one and shows no message. The keyring then stays closed to the correct password.
Acceptance criteria
Requirement: Bus without display variables
The function _start_session_bus SHALL start dbus-daemon with neither DISPLAY nor WAYLAND_DISPLAY in the child environment.
Scenario: Bus start with a display set
- WHEN DISPLAY and WAYLAND_DISPLAY are set in the parent process and _start_session_bus starts the bus with run_subprocess mocked
- THEN The environment and the allowed variables of the dbus-daemon call contain neither DISPLAY nor WAYLAND_DISPLAY
Requirement: Daemon without display variables
The function _unlock_keyring SHALL start gnome-keyring-daemon with neither DISPLAY nor WAYLAND_DISPLAY in the child environment.
Scenario: Unlock with a display set
- WHEN DISPLAY and WAYLAND_DISPLAY are set in the parent process and _unlock_keyring runs with run_subprocess mocked
- THEN The gnome-keyring-daemon call keeps DBUS_SESSION_BUS_ADDRESS and XDG_RUNTIME_DIR and contains neither DISPLAY nor WAYLAND_DISPLAY
Requirement: No password prompt in post-start
The post-start command SHALL NOT prompt for the keyring password, even when the unlock marker exists and stdin is a terminal.
Scenario: Post-start with a pending marker
- WHEN post_start runs with the marker .keyring-unlock-pending present and stdin reported as a terminal
- THEN _unlock_keyring is not called, the marker stays, and the shell hook remains the only prompt
Requirement: Backup after unlock
The unlock command SHALL copy login.keyring to a backup folder after each successful unlock, with file mode 0600 in a folder with mode 0700.
Scenario: Successful unlock
- WHEN _unlock_keyring ends with the collection unlocked and a login.keyring file exists
- THEN The backup folder holds a time-stamped copy of the file with the same content, and the modes are 0600 and 0700
Requirement: Backup retention
The unlock command SHALL keep only the last five backup copies and SHALL NOT add a copy whose content equals the newest copy.
Scenario: Sixth different backup
- WHEN Five backups exist and a successful unlock finds a login.keyring with new content
- THEN The folder holds five copies, the oldest is gone, and an unlock with unchanged content adds no copy
Requirement: No backup after a wrong password
The unlock command SHALL NOT write a backup when the keyring stays locked or is missing after the unlock attempt.
Scenario: Wrong password
- WHEN _unlock_keyring ends with the collection still locked
- THEN The backup folder gets no new file
Requirement: Backup failure does not fail unlock
A failure to write a backup SHALL NOT make a successful unlock fail.
Scenario: Unwritable backup folder
- WHEN The copy raises OSError after a successful unlock
- THEN _unlock_keyring returns True and logs the failure
Requirement: Error names the backup folder
The wrong-password error SHALL name the backup folder as well as the keyring file.
Scenario: Wrong password message
- WHEN _unlock_keyring ends with the collection locked
- THEN The printed error contains the path of the keyring file and the path of the backup folder
Existing Tool Considered
No check has run. gnome-keyring is the tool in use, and it has no setting that stops it from taking a rejected unlock password as the new login password. No other open library covers this need, because the fix removes two environment variables and one prompt, and adds a short file copy with the standard library. The cost to build it is small: about one pull request, a few tens of lines and their tests, and a few hours.
Key questions
- Which variables let the GUI prompt open, and where does the code pass them?: _start_session_bus and _unlock_keyring pass DISPLAY and WAYLAND_DISPLAY through extra_allowed_env. Removing them from both calls stops the bus and the daemon from seeing a display. A client unlock request on a bus with no display is dismissed at once and the collection stays locked. [sources: src/devops_cli/commands/devcontainer.py, tests/core/test_subprocess_env_boundary.py]
- How do we make sure the child gets no display variable?: Remove both names from extra_allowed_env in the two calls and assert in tests that the child environment has neither. This uses the existing allow-list boundary of run_subprocess and needs no new mechanism. (best practice) [sources: src/devops_cli/commands/devcontainer.py]
- Chosen: Remove the names from extra_allowed_env. It uses the existing allow-list and is the smallest change.
- Rejected: Add a new deny list for display variables. It adds code that the allow-list makes unneeded.
- What happens to the post-start password prompt?: Remove the prompt and the code that only it uses (the call in post_start and the CONST_KEYRING_PROMPT_TIMEOUT_SECONDS import). The shell hook in ~/.bashrc and ~/.zshrc stays the way to unlock, because an interactive terminal sends each key once. (best practice) [sources: src/devops_cli/commands/devcontainer.py]
- Chosen: Remove the prompt. The lifecycle terminal doubles each key, so the prompt can never give the correct password.
- Rejected: Undo the doubling of the input. It guesses the terminal behavior, and a password with repeated characters would break.
- Where do the backups go and how many stay?: Use a folder named keyrings-backup beside the keyrings folder under XDG_DATA_HOME, with mode 0700. Keep the last five copies, and skip a copy whose content equals the newest copy. The folder is outside the keyrings folder, so gnome-keyring does not scan the copies as keyrings. (best practice) [sources: src/devops_cli/commands/devcontainer.py]
- Chosen: Sibling folder keyrings-backup, last five copies. It keeps the copies away from the folder that the daemon reads, and five copies bound the disk use.
- Rejected: Backup inside the keyrings folder. The daemon could read the copies as keyrings.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 9, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(devcontainer)scope of the title gives the scope.A recurring bug that corrupts the keyring password and locks out all stored credentials.Users lose access to every credential in the keyring and must recover it by hand.The fix changes daemon startup flags, removes a prompt, and adds a backup step.Both items work on the in-container keyring, but #452 adds the keyring and #candidate fixes a bug in its unlock flow.devops-cli-service commentedon Nov 9, 2026
Status set to Ready at f9e47b7 (see proposed design in issue body).
fix(devcontainer): a rejected unlock password becomes the keyring pas…
devops-cli-service commentedon Nov 9, 2026
Released in v0.101.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.101.1
devops-cli-service commentedon Nov 9, 2026
Live since 2026-11-09 17:44 UTC