Skip to content

fix: remove rbash — too restrictive for practical use#2629

Merged
tusharmath merged 11 commits intoantinomyhq:mainfrom
majiayu000:fix/issue-2559-rbash-fallback
Mar 23, 2026
Merged

fix: remove rbash — too restrictive for practical use#2629
tusharmath merged 11 commits intoantinomyhq:mainfrom
majiayu000:fix/issue-2559-rbash-fallback

Conversation

@majiayu000
Copy link
Contributor

@majiayu000 majiayu000 commented Mar 22, 2026

Summary

Remove rbash (restricted bash) as the shell used in restricted mode, as it was too restrictive to be useful and prevented normal operations from working.

Context

Restricted mode (--restricted / -r flag) was previously implemented by swapping the user's shell for /bin/rbash, the restricted variant of bash. While this sounds like a security feature, rbash blocks so many basic operations (path execution, directory changes, redirects) that the agent couldn't do anything meaningful. The intended security boundary is better enforced through the existing permissions feature, not at the shell binary level.

Changes

  • crates/forge_infra/src/env.rs: Removed the rbash branch from get_shell_path() — restricted mode now falls through to the same shell resolution as unrestricted mode (user's $SHELL or /bin/sh). Updated doc comment to reflect the new semantics.
  • crates/forge_infra/src/executor.rs: Removed the rbash override in prepare_command() that was forcing rbash regardless of the configured shell.
  • crates/forge_main/src/cli.rs: Updated the --restricted flag description to clarify it enables the permissions feature, not a restricted shell.
  • crates/forge_services/src/tool_services/shell.rs: Removed stale doc comment referencing rbash.

Testing

# Verify no compilation errors
cargo check --all-features --workspace

# Run tests
cargo insta test --accept

# Manual: run with --restricted flag and confirm commands execute normally
forge --restricted

Links

When the default shell is set to rbash, shell commands fail because
rbash restricts many operations needed for normal command execution.
This adds a resolve_shell() function that detects rbash and falls back
to /bin/bash, /bin/zsh, or /bin/sh (in that order), applied in both
the environment shell resolution and the command executor.

Closes antinomyhq#2559

Signed-off-by: majiayu000 <1835304752@qq.com>
@CLAassistant
Copy link

CLAassistant commented Mar 22, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ tusharmath
❌ majiayu000
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Mar 22, 2026
@majiayu000 majiayu000 marked this pull request as ready for review March 22, 2026 03:48
majiayu000 and others added 2 commits March 22, 2026 19:18
Replace resolve_shell() fallback logic with simply using bash
instead of rbash, as suggested in PR antinomyhq#2629 review.

Signed-off-by: majiayu000 <1835304752@qq.com>
majiayu000 and others added 4 commits March 23, 2026 01:26
The shell resolution is already handled in env.rs get_shell_path(),
so the conditional in executor.rs was unnecessary duplication.
Remove the restricted field from ForgeCommandExecutorService entirely.

Signed-off-by: majiayu000 <1835304752@qq.com>
@tusharmath tusharmath enabled auto-merge (squash) March 23, 2026 13:15
@tusharmath tusharmath changed the title fix: add fallback from rbash to bash/zsh/sh for command execution fix: remove rbash — too restrictive for practical use Mar 23, 2026
@tusharmath tusharmath merged commit d96f8f9 into antinomyhq:main Mar 23, 2026
9 of 10 checks passed
@majiayu000 majiayu000 deleted the fix/issue-2559-rbash-fallback branch March 23, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Shell commands fail when default shell is set to rbash

3 participants