Skip to content

Prevent passing of a malicious command via DIALOGCMD env#94

Open
lkocman wants to merge 3 commits into
openSUSE:mainfrom
lkocman:sanity
Open

Prevent passing of a malicious command via DIALOGCMD env#94
lkocman wants to merge 3 commits into
openSUSE:mainfrom
lkocman:sanity

Conversation

@lkocman
Copy link
Copy Markdown
Collaborator

@lkocman lkocman commented May 19, 2026

  • Drop the legacy dialog support
  • Users can no longer pass a malicious command via DIALOGCMD environment variable
  • The script doesn't rely on environment variables through sudo
  • When elevated, the script re-validates DIALOGCMD by running the detection logic again
  • This defense-in-depth approach ensures DIALOGCMD is always a legitimate system command

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes user-controlled DIALOGCMD env var handling to prevent a potential privilege-escalation vector where a malicious value could be passed across the sudo boundary. The elevated re-exec no longer forwards DIALOGCMD, and the script re-detects it after elevation.

Changes:

  • Unset any inherited DIALOGCMD and only auto-detect susedialog/dialog from PATH.
  • Remove DIALOGCMD="$DIALOGCMD" from the exec sudo invocation so detection re-runs as root.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lkocman
Copy link
Copy Markdown
Collaborator Author

lkocman commented May 19, 2026

The failed pipeline is fine it's only TW snapshot change

Comment thread opensuse-migration-tool Outdated
# This prevents privilege escalation via sudo DIALOGCMD injection
unset DIALOGCMD

if DIALOGCMD=$(command -v susedialog 2>/dev/null); then
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.

the issue is that this block should only be executed when EUID is 0. right now you run this as non-root and then make use of the evaluation result (under the attackers control) in the elavated run.

you must do this only when root in a clean environment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oky, I'll rework this. I'm still contemplating if it's really worth to support the legacy dialog ... maybe it would be simpler to just support susedialog also from openqa perspective ...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oky I think it's addressed now. I also removed fallback for legacy dialog.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread opensuse-migration-tool
Comment on lines +180 to +184
# Keep only terminal-related vars needed by dialog.
exec sudo env -i \
PATH="/usr/sbin:/usr/bin:/sbin:/bin" \
TERM="${TERM:-linux}" \
COLORTERM="${COLORTERM:-}" \
Copy link
Copy Markdown
Member

@dirkmueller dirkmueller May 20, 2026

Choose a reason for hiding this comment

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

@lkocman please explicitly source the proxy information (iirc /etc/sysconfig/proxy) ?

passing down the proxy information would make sense though. many enterprise users are behind a corporate proxy/security gateway.

Comment thread opensuse-migration-tool
Comment on lines +194 to +195
unset DIALOGCMD
if DIALOGCMD=$(command -v susedialog 2>/dev/null); then
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.

can we use this suggestion? I agree it would be safer, but I'm not sure why we need to probe in the first place (rather than just hardcode)?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread opensuse-migration-tool
# Resolve susedialog only after privilege handling.
# This prevents using a value resolved in an unprivileged context in the elevated run.
unset DIALOGCMD
if DIALOGCMD=$(command -v susedialog 2>/dev/null); then
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This one I'd actually consider. However I very often develop susedialog with this tool and run it from non /usr/bin locations ...

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.

Yes, I also recommend using type instead of command

Comment thread opensuse-migration-tool
Comment on lines +183 to +187
# Keep only terminal-related vars needed by dialog.
exec sudo env -i \
PATH="/usr/sbin:/usr/bin:/sbin:/bin" \
TERM="${TERM:-linux}" \
COLORTERM="${COLORTERM:-}" \
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Here I think we might not need to preserve them working with default root variables should be fine.

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