Skip to content

Bug 2021342 - Keep the enterprise-managed SDR unlocked and fail closed on unlock failure#1162

Open
beurdouche wants to merge 1 commit into
mozilla:enterprise-mainfrom
beurdouche:bug-2021342-sdr-primary-password
Open

Bug 2021342 - Keep the enterprise-managed SDR unlocked and fail closed on unlock failure#1162
beurdouche wants to merge 1 commit into
mozilla:enterprise-mainfrom
beurdouche:bug-2021342-sdr-primary-password

Conversation

@beurdouche

Copy link
Copy Markdown
Member

The enterprise storage-encryption feature sets the NSS internal token's primary password to the console-supplied primarySecret and unlocks it once at startup. Two gaps let a primary-password prompt reach the user for a secret they cannot supply (about:logins, password import, Sync on startup):

  • EnterpriseStorageEncryption.load set the password on a fresh token via changePassword("", primarySecret) but never logged the token in (PK11_ChangePW does not authenticate), and its only error handling was console.error. Make the login explicit and symmetric across the fresh and returning branches, verify pk11token.isLoggedIn, and fail the launch with a dedicated exit code (FeltEncryptionExitCode_UnlockFailed) if any step fails instead of continuing half-unlocked.

  • Any CLEAR_AUTH_TOKENS clear (Clear Recent History, sanitize, site-data) routed through SecretDecoderRing::Logout / LogoutAndTeardown ran PK11_LogoutAll, re-locking the internal token mid-session with no re-login. Skip the token logout while the primary password is enterprise-managed; the rest of the teardown (TLS cache, connection pruning) still runs.

Comment thread browser/components/BrowserGlue.sys.mjs Outdated
Comment thread security/manager/ssl/SecretDecoderRing.cpp

@simon-friedberger simon-friedberger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm as long as the tests all pass, I suspect they don't so those would need fixing

Comment thread browser/components/BrowserGlue.sys.mjs Outdated
Comment thread toolkit/components/felt/rust/nsIFelt.idl Outdated
@beurdouche

Copy link
Copy Markdown
Member Author

Looking into this now.

…d on unlock failure

The enterprise storage-encryption feature sets the NSS internal token's primary
password to the console-supplied primarySecret and unlocks it once at startup.
A primary-password prompt could still reach the user for a secret they cannot
supply (about:logins, password import, Sync on startup). Fixes:

- EnterpriseStorageEncryption.load set the password on a fresh token via
  changePassword("", primarySecret) but never logged the token in (PK11_ChangePW
  does not authenticate). Make the login explicit, verify pk11token.isLoggedIn,
  and fail the launch with a dedicated exit code
  (FeltEncryptionExitCode_SdrTokenUnlockFailed) if any step fails instead of
  continuing half-unlocked.

- Handle that exit code in FeltProcessParent.handleRestartAfterAbnormalExit:
  surface a dedicated "cannot unlock your profile" error
  (felt-error-sdr-token-unlock-failed) instead of counting it as a crash and
  looping through restarts.

- The ClearData CLEAR_AUTH_TOKENS path (SecretDecoderRing::LogoutAndTeardown)
  ran PK11_LogoutAll, re-locking the internal token mid-session with no
  re-login. Skip that logout while the primary password is enterprise-managed;
  the non-token teardown (TLS cache, connection pruning) still runs. Logout()
  is left unguarded as it has no production caller.

- Add an enterprise-gated regression test asserting the token stays logged in
  through logoutAndTeardown.
@beurdouche
beurdouche force-pushed the bug-2021342-sdr-primary-password branch from 4cfc3d9 to e76cd66 Compare July 21, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants