Skip to content

fix: solve CWE 23 - #15761

Closed
alejandro-vaz wants to merge 1 commit into
omacom:quattrofrom
alejandro-vaz:solve-cwe-23
Closed

alejandro-vaz wants to merge 1 commit into
omacom:quattrofrom
alejandro-vaz:solve-cwe-23

Conversation

@alejandro-vaz

Copy link
Copy Markdown

this PR solves the weakness affecting omarchy-refresh-config which accepts any path relative path traversal and can leak data outwards

it is solved by verifying the relative path stays within config

@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects the config refresh workflow used by users and helper commands.

The PR appears safe to merge, with a non-blocking request to test the new path checks.

Summary

Adds path checks to omarchy-refresh-config before it backs up or copies files.

  • Config refreshes stay inside the shipped and user config folders.

Reviews (1) · Last reviewed commit: "fix: solve CWE 23" · Reviewed by Greptile

Comment on lines +43 to +50
user_config_file=$(realpath -m -- "$user_config_root/$config_file") || {
echo "Could not resolve user config path: $config_file" >&2
exit 1
}

if [[ $user_config_file != "$user_config_root/"* ]]; then
echo "Config path must stay inside .config: $config_file" >&2
exit 1

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.

P2 Path checks lack tests

The new path checks have no regression tests. refresh-config-test.sh only covers copying a normal file and rejecting a missing source, so a later change could undo these checks without failing the tests.

Add cases for absolute paths, .. components, source and destination symlinks that escape their roots, and a missing destination directory. For rejected paths, assert that outside files stay unchanged.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@greptile-apps

greptile-apps Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P2 Path checks lack tests bin/omarchy-refresh-config:50 ▶

    The new path checks have no regression tests. refresh-config-test.sh only covers copying a normal file and rejecting a missing source, so a later change could undo these checks without failing the tests.

    Add cases for absolute paths, .. components, source and destination symlinks that escape their roots, and a missing destination directory. For rejected paths, assert that outside files stay unchanged.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for this. I read the change against bin/omarchy-refresh-config on quattro and every place that calls it, and didn't run the change on a worker. This pull request has no class label yet because Claude Opus 5.5 and Codex Medium, classifying it separately, didn't agree on what it is. Opus read it as an enhancement and Codex read it as a bug fix.

The question is whether this fixes something broken. Every caller in the repository (the omarchy-refresh-* commands and the migrations) passes a fixed path like hypr/bindings.lua. Apart from those, the path only comes from the person running the command, and they can already read and write anything a traversal path would reach. So I couldn't find a case where ../ lets anyone reach something they couldn't reach before. That makes this hardening rather than a fix.

There's also a behaviour change to weigh. realpath -m follows symlinks under ~/.config, so a user who keeps ~/.config/hypr as a symlink into a dotfiles repository (GNU Stow, for example) gets "Config path must stay inside .config" and no refresh. Today that refresh works. I confirmed this with realpath itself against a symlinked directory in a scratch location.

This now waits on the maintainer to decide whether the hardening is wanted.

@aholbreich

Copy link
Copy Markdown
Contributor

Thanks @alejandro-vaz. The .. and absolute-path rejection landed in #10413 (eb701f1f9), and #8423 is closed. The part that's left, the realpath containment, refuses a refresh when ~/.config/hypr is a symlink into a dotfiles repo. I checked it in a scratch HOME: hypr/hyprland.lua fails with "Config path must stay inside .config", while current quattro refreshes it. The merged AGENTS.md now says the check is lexical on purpose, so symlinked dotfiles keep working. With that and the conflict, I think this can be closed as superseded.

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