Skip to content

Strip Kernel browser settings from Local State when loading a profile - #514

Closed
Sayan- wants to merge 4 commits into
mainfrom
hypeship/strip-kernel-local-state
Closed

Sayan- wants to merge 4 commits into
mainfrom
hypeship/strip-kernel-local-state

Conversation

@Sayan-

@Sayan- Sayan- commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Kernel's Chromium build stores browser-wide settings set over CDP in Chrome's Local State, under a top-level kernel object (fingerprint overrides and request header rules). Saved profiles archive the whole user-data directory, so a profile saved from a browser with these settings brings them back into every browser that loads it.

When /chromium/configure installs a profile, it now removes the kernel object from the unpacked profile's Local State before swapping it in for user-data. Like stripProfileSessionRestore, only the live copy is changed; the stored archive is not. This covers archives saved before the API stopped including these settings (kernel/kernel#5396).

A missing Local State is a no-op. If the file cannot be read, parsed or written, configure logs a warning and installs the profile anyway. A file without a kernel object is not rewritten, and the rewrite keeps the file's owner and mode.

Validation

  • New unit test for the strip: removes only kernel, keeps large integers and URLs with &, keeps the file mode, leaves files without kernel byte-for-byte unchanged, treats a missing file as a no-op, and reports invalid JSON.
  • Configure now runs both profile cleanups (session restore and Local State) through one helper, sanitizePreparedProfile. Its test covers both start_url cases and confirms an unreadable Local State does not fail the load. Removing the Local State strip from the helper fails the test.
  • Not tested: the chromiumConfigureRestart call into that helper, which needs a running Chromium under supervisor. Not exercised end to end in an image.

🤖 Generated with Claude Code


Note

Medium Risk
Changes profile install behavior in the Chromium configure restart path; mistaken stripping could affect fingerprint/header behavior, but Local State failures are non-blocking by design.

Overview
When /chromium/configure installs a profile archive, profile prep now runs through sanitizePreparedProfile, which still removes Default/Sessions only when a start_url navigation is requested, and always strips the top-level kernel object from the unpacked profile’s Local State so saved fingerprint/header settings from another browser are not reapplied.

stripProfileKernelLocalState parses and rewrites Local State in place on the live unpacked copy only; missing files or absent kernel are no-ops. Errors reading/parsing/writing Local State are warned and ignored so configure can still install the profile. Unit tests cover the strip helper and the combined sanitizer (with/without navigation, and invalid Local State not failing the load).

Reviewed by Cursor Bugbot for commit 64e3b3f. Bugbot is set up for automated code reviews on this repo. Configure here.

Sayan- and others added 2 commits November 9, 2026 22:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fd35e98. Configure here.

}
if err := os.WriteFile(path, bytes.TrimRight(buf.Bytes(), "\n"), 0o644); err != nil {
return fmt.Errorf("write Local State: %w", err)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Failed rewrite can corrupt Local State

Medium Severity

A write error in stripProfileKernelLocalState still installs the profile. os.WriteFile truncates Local State before writing, so a failed write can leave empty or partial JSON. Configure then swaps that copy in, which can drop os_crypt and other browser-wide prefs instead of keeping the original file.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fd35e98. Configure here.

Sayan- and others added 2 commits November 9, 2026 23:20
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Sayan- Sayan- closed this Nov 10, 2026
@Sayan-
Sayan- deleted the hypeship/strip-kernel-local-state branch November 10, 2026 00:52
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.

1 participant