Skip to content

Verify migration markers instead of trusting their existence - #14827

Open
postqcoin wants to merge 3 commits into
omacom:quattrofrom
postqcoin:fix/migration-marker-verification
Open

postqcoin wants to merge 3 commits into
omacom:quattrofrom
postqcoin:fix/migration-marker-verification

Conversation

@postqcoin

Copy link
Copy Markdown

Problem

omarchy-migrate decided whether a migration had run with a single
[[ ! -f $marker ]] test on ~/.local/state/omarchy/migrations/<filename>.
Markers were empty files, so any process running as the user could touch a
marker for a migration that never ran — including security-hardening ones like
the sshd/FIDO2/udev/polkit repairs — and it would be skipped forever, silently.

Fix

Markers now record the sha256 hash of the migration file that wrote them.
omarchy-migrate treats a marker with missing or unexpected content as
pending, so the (idempotent) migration runs instead of being silently skipped.
A planted empty marker no longer suppresses anything.

Existing empty markers from before this change will cause their migrations to
run once more on the next omarchy-migrate — safe, because migrations are
required to be idempotent.

Changes

  • bin/omarchy-migrate: new migration_completed() (marker exists AND content
    matches sha256 of the migration file); both --pending and the run loop use
    it; completion writes the hash instead of touch
  • test/shell.d/migrate-marker-test.sh: new — planted/forged markers don't
    suppress, genuine runs record the hash and skip on re-run
  • agents/skills/migrations.md: documented the marker content format

Testing

  • New migrate-marker-test.sh: 5/5 pass
  • Existing migrate-wrapper-test.sh, migrate-notify-test.sh,
    migrate-scope-test.sh: all pass

@postqcoin postqcoin closed this Oct 10, 2026
@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 2/5

[Critical impact] Changes how migration completion is verified and tracked.

The PR should not merge while replay can overwrite user choices and writable hashes can still suppress security repairs.

Findings

  1. P1 Replay overwrites later user choices ▶
  2. P1 Security Planted hashes still skip repairs ▶

Summary

The PR replaces empty completion markers with migration-file hashes.

  • Migration markers must match their scripts to count as complete.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read migration and marker] --> B{Marker matches file hash?}
  B -->|Yes| C[Skip migration]
  B -->|No| D{Pending-only mode?}
  D -->|Yes| E[List migration]
  D -->|No| F[Run migration]
  F --> G[Write file hash to marker]
Loading

Reviews (2) · Last reviewed commit: "Verify migration markers instead of trus..." · Reviewed by Greptile

Comment thread bin/omarchy-migrate
Comment on lines +69 to +70
actual=$(cat "$marker" 2>/dev/null) || return 1
[[ $actual == $expected ]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Replay overwrites later user choices

Rejecting every empty marker replays completed migrations on existing installs. That can undo later user choices:

  • migrations/1790457067.sh changes any exact Node version back to "latest".
  • migrations/1791376887.sh restores overlay scrollbars after a user removes them.

Fresh installs are also affected because omarchy-provision-user still seeds empty markers with touch. Audit historical migrations before forcing this replay, and update the install-time marker writer to match the new format.

Comment thread bin/omarchy-migrate
Comment on lines +67 to +70
expected=$(sha256sum "$file" 2>/dev/null | cut -d' ' -f1) || return 1
[[ -n $expected ]] || return 1
actual=$(cat "$marker" 2>/dev/null) || return 1
[[ $actual == $expected ]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 security Planted hashes still skip repairs

A process running as the user can still suppress a security migration without running it. It can read the migration file, calculate its hash, and write that hash into the user-owned marker. migration_completed then accepts the marker and skips the script, including the repair that restores polkit brute-force protection.

This rejects empty or damaged markers, but does not establish that a migration ran. To meet the stated security goal, use a completion record the attacking process cannot write, or check the protected state before skipping security repairs.

How this was verified: The runner accepts a matching hash from a marker under the user's home directory and skips the polkit repair without checking whether brute-force protection was restored.

@postqcoin postqcoin reopened this Oct 10, 2026
@jandrusk

Copy link
Copy Markdown

Thanks for digging into this. I think there are two problems that block it as written:

  1. Fresh installs would replay every migration. bin/omarchy-provision-user seeds a new user's state by touching a marker for every shipped migration (around line 125), so a new install skips history. With this change those empty markers count as pending, and the first omarchy-migrate runs all ~164 historical migrations on a brand-new machine. Existing users get the same full replay on their next update. "Idempotent" holds for most migrations, but replaying all of them at once is a big behavior change (Greptile also points out some of them rewrite user choices). Editing a shipped migration file, which does happen, would also change its hash and re-run it.

  2. The hash doesn't add integrity. The marker dir is user-writable and the migration files are public, so any process that can touch a marker can just as easily write sha256sum migration.sh into it. A same-user process can also edit ~/.bashrc, hyprland config, etc., so I don't think marker contents are a meaningful boundary.

If the goal is to detect corrupted or partial markers, a lighter option is to write the hash on completion going forward and treat only a marker whose content is non-empty and wrong as pending, leaving empty legacy markers as completed:

migration_completed() {
  local file=$1 marker=$2 actual
  [[ -f $marker ]] || return 1
  actual=$(<"$marker")
  [[ -z $actual ]] && return 0   # legacy / provisioned marker
  [[ $actual == "$(sha256sum "$file" | cut -d' ' -f1)" ]]
}

omarchy-provision-user would also need to write the same format, and it'd be worth a test that runs provisioning and then omarchy-migrate --pending and expects nothing pending.

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.

2 participants