Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Prevent Web UI execution of sensitive CLI commands#99

Open
SlasshyOverhere wants to merge 1 commit into
mainfrom
sentinel-fix-blocked-web-cli-commands-5957204070675577767
Open

πŸ›‘οΈ Sentinel: [HIGH] Prevent Web UI execution of sensitive CLI commands#99
SlasshyOverhere wants to merge 1 commit into
mainfrom
sentinel-fix-blocked-web-cli-commands-5957204070675577767

Conversation

@SlasshyOverhere
Copy link
Copy Markdown
Owner

@SlasshyOverhere SlasshyOverhere commented Apr 5, 2026

🚨 Severity: HIGH
πŸ’‘ Vulnerability: Interactive and destructive CLI commands could be executed non-interactively via the Web UI's /api/cli/run endpoint, bypassing intended CLI-only safety mechanisms and user prompts.
🎯 Impact: Attackers or malicious scripts with access to the local Web UI could potentially trigger destructive actions, modify authentication settings, or initiate synchronization without proper confirmation or interactive context.
πŸ”§ Fix: Added vault2fa, totp, sync, duress, autolock, settings, theme, update, and desktop to the BLOCKED_WEB_CLI_COMMANDS Set in src/webui/server.ts, effectively preventing their execution via the Web UI.
βœ… Verification: Ensure the listed commands are blocked by BLOCKED_WEB_CLI_COMMANDS and cannot be invoked from the /api/cli/run endpoint.


PR created automatically by Jules for task 5957204070675577767 started by @SlasshyOverhere

Summary by CodeRabbit

  • Bug Fixes
    • Restricted additional CLI commands from being executed through the Web UI.

* Added interactive and destructive CLI commands (`vault2fa`, `totp`, `sync`, `duress`, `autolock`, `settings`, `theme`, `update`, `desktop`) to `BLOCKED_WEB_CLI_COMMANDS` in `server.ts`.
* Prevents bypass of intended CLI-only safety mechanisms via the Web UI's `/api/cli/run` endpoint.
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings April 5, 2026 14:52
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 5, 2026

πŸ“ Walkthrough

Walkthrough

The BLOCKED_WEB_CLI_COMMANDS list in the Web UI server has been expanded to block an additional nine CLI entrypoints (vault2fa, totp, sync, duress, autolock, settings, theme, update, desktop), extending protections against executing these commands through the Web UI interface.

Changes

Cohort / File(s) Summary
CLI Command Blocklist Expansion
src/webui/server.ts
Extended BLOCKED_WEB_CLI_COMMANDS array to block nine additional CLI entrypoints alongside the existing six blocked commands, preventing execution via Web UI endpoints.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰✨ A blocklist grows, nine commands more to shield,
The Web UI's gates now firmly sealed,
No vaults, no syncs, no themes to breach,
Safe from the Web, now out of reach! πŸ›‘οΈ

πŸš₯ Pre-merge checks | βœ… 3
βœ… Passed checks (3 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly and specifically identifies the main change: preventing Web UI execution of sensitive CLI commands by expanding the blocked commands list.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel-fix-blocked-web-cli-commands-5957204070675577767

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 and usage tips.

Copy link
Copy Markdown

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

This PR hardens the Web UI’s /api/cli/run endpoint by expanding the server-side blocklist of CLI commands that must not be runnable from the Web UI context, reducing the risk of destructive or sensitive operations being triggered non-interactively.

Changes:

  • Expanded BLOCKED_WEB_CLI_COMMANDS to include additional sensitive commands (e.g., update, desktop, settings-related commands).
  • Reformatted the blocklist into a multi-line Set initializer for readability.

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/webui/server.ts
const CLI_RUN_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
const BLOCKED_WEB_CLI_COMMANDS = new Set(['web', 'ui', 'destruct', 'init', 'auth', 'delete']);
const BLOCKED_WEB_CLI_COMMANDS = new Set([
'web', 'ui', 'destruct', 'init', 'auth', 'delete',
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

delete has an alias rm in the CLI (see src/index.ts), but rm is not included in BLOCKED_WEB_CLI_COMMANDS. As a result, /api/cli/run can still perform deletions by running rm .... Add rm to the blocked set (and generally ensure aliases for blocked commands are also blocked).

Suggested change
'web', 'ui', 'destruct', 'init', 'auth', 'delete',
'web', 'ui', 'destruct', 'init', 'auth', 'delete', 'rm',

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

πŸ€– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/webui/server.ts`:
- Around line 50-54: The blocklist check currently only tests canonical IDs in
BLOCKED_WEB_CLI_COMMANDS but runCliCommand matches the first token and CLI
definitions expose aliases (e.g., totp|otp, duress|panic, delete|rm,
2fa-setup|vault-2fa|2fa), so update runCliCommand to resolve the invoked command
token to its canonical command before checking the blocklist (or alternatively
check the token against both canonical and alias names). Locate the CLI
registry/definitions in src/cli/shell.ts (where aliases are declared) and
implement a lookup function (e.g., resolveCliCommandAlias(token) used by
runCliCommand) that maps aliases to the canonical ID, then enforce blocking by
testing the resolved canonical ID against BLOCKED_WEB_CLI_COMMANDS.
πŸͺ„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5bd31266-c8a8-40f7-b0af-5d15f0d6c043

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 1cdcca9 and 4c9d3e6.

πŸ“’ Files selected for processing (1)
  • src/webui/server.ts

Comment thread src/webui/server.ts
Comment on lines +50 to +54
const BLOCKED_WEB_CLI_COMMANDS = new Set([
'web', 'ui', 'destruct', 'init', 'auth', 'delete',
'vault2fa', 'totp', 'sync', 'duress', 'autolock',
'settings', 'theme', 'update', 'desktop'
]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Alias-based command bypass remains possible in Web UI blocklist.

Line 50–54 blocks canonical command IDs, but runCliCommand does exact first-token matching, and the CLI definitions expose aliases (e.g., totp|otp, duress|panic, delete|rm, 2fa-setup|vault-2fa|2fa in src/cli/shell.ts Lines 179–212). This means sensitive commands can still be invoked via aliases through /api/cli/run.

πŸ”’ Proposed hardening patch
 const BLOCKED_WEB_CLI_COMMANDS = new Set([
-  'web', 'ui', 'destruct', 'init', 'auth', 'delete',
-  'vault2fa', 'totp', 'sync', 'duress', 'autolock',
+  'web', 'ui', 'destruct', 'init', 'auth', 'delete', 'rm',
+  'vault2fa', '2fa-setup', 'vault-2fa', '2fa',
+  'totp', 'otp', 'sync', 'duress', 'panic', 'autolock',
   'settings', 'theme', 'update', 'desktop'
 ]);
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const BLOCKED_WEB_CLI_COMMANDS = new Set([
'web', 'ui', 'destruct', 'init', 'auth', 'delete',
'vault2fa', 'totp', 'sync', 'duress', 'autolock',
'settings', 'theme', 'update', 'desktop'
]);
const BLOCKED_WEB_CLI_COMMANDS = new Set([
'web', 'ui', 'destruct', 'init', 'auth', 'delete', 'rm',
'vault2fa', '2fa-setup', 'vault-2fa', '2fa',
'totp', 'otp', 'sync', 'duress', 'panic', 'autolock',
'settings', 'theme', 'update', 'desktop'
]);
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/webui/server.ts` around lines 50 - 54, The blocklist check currently only
tests canonical IDs in BLOCKED_WEB_CLI_COMMANDS but runCliCommand matches the
first token and CLI definitions expose aliases (e.g., totp|otp, duress|panic,
delete|rm, 2fa-setup|vault-2fa|2fa), so update runCliCommand to resolve the
invoked command token to its canonical command before checking the blocklist (or
alternatively check the token against both canonical and alias names). Locate
the CLI registry/definitions in src/cli/shell.ts (where aliases are declared)
and implement a lookup function (e.g., resolveCliCommandAlias(token) used by
runCliCommand) that maps aliases to the canonical ID, then enforce blocking by
testing the resolved canonical ID against BLOCKED_WEB_CLI_COMMANDS.

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