Skip to content

Make htop_history reside in $XDG_STATE_HOME and harden accessing the file against symlink attacks - #2097

Open
fasterit wants to merge 2 commits into
htop-dev:mainfrom
fasterit:move-htop_history-and-harden-access
Open

Make htop_history reside in $XDG_STATE_HOME and harden accessing the file against symlink attacks#2097
fasterit wants to merge 2 commits into
htop-dev:mainfrom
fasterit:move-htop_history-and-harden-access

Conversation

@fasterit

Copy link
Copy Markdown
Member

Fixes GHSA-46qw-qjgv-jhrw, thank you 0xseiryuu.
Resolves #1944, thank you @Explorer09.
Resolves #2089.

Assisted-by: OpenCode Zen

…file against symlink attacks

Fixes GHSA-46qw-qjgv-jhrw, thank you 0xseiryuu.
Resolves htop-dev#1944, thank you @Explorer09.
Resolves htop-dev#2089.

Assisted-by: OpenCode Zen
@fasterit fasterit added this to the 3.6.0 milestone Aug 30, 2026
@fasterit fasterit added code quality ♻️ Code quality enhancement security 👮 Issues with security implications labels Aug 30, 2026
Comment thread Settings.c Fixed
Comment thread Settings.c Fixed
Comment thread Settings.c Fixed
Comment thread Settings.c Fixed
@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change stores search and filter history below the XDG state directory. It creates the required directory and migrates a legacy history file when appropriate. History loading and saving now reject symlinks and invalid ownership or permission states. The command-line setup uses the new path helper. The manual documents the new location and migration behavior.

Assessment against linked issues

Objective Addressed Explanation
Store history at $XDG_STATE_HOME/htop/htop_history, use the $HOME/.local/state fallback, and preserve legacy-file compatibility [#1944]
Avoid following htoprc symlinks when storing history [#2089]

Suggested reviewers: benbe

Poem

History leaves the config shore
XDG state receives it once more
Symlinks meet a guarded gate
Safe writes wait and validate
Legacy records move with care
The new path keeps them there

Merge Risk: 🟡 Moderate · up to 12174

The PR moves and hardens history persistence, but parent-directory symlinks can still redirect reads or writes, while migration races can delete a replacement legacy file or leave partial history authoritative. These bounded security and data-integrity risks should be fixed or explicitly accepted before merging.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ef7ad5ab-84c1-4f19-9548-90c7734a3247

📥 Commits

Reviewing files that changed from the base of the PR and between e0dd9db and 34a1847.

📒 Files selected for processing (6)
  • CommandLine.c
  • History.c
  • History.h
  • Settings.c
  • Settings.h
  • htop.1.in

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread History.c Outdated
Comment thread Settings.c Outdated
Assisted-by: CodeRabbitAI, OpenCode Zen
Comment thread Settings.c Dismissed

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 55ba3159-7c1a-417f-8b07-b9eaa6698d8c

📥 Commits

Reviewing files that changed from the base of the PR and between 34a1847 and 1217436.

📒 Files selected for processing (5)
  • CommandLine.c
  • History.c
  • Settings.c
  • Settings.h
  • htop.1.in

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread Settings.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality ♻️ Code quality enhancement security 👮 Issues with security implications

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't follow htoprc if it's a symlink to store htop_history htop_history storage location and $XDG_STATE_HOME

2 participants