Standalone Penetration Testing agent cannot execute Bash in required sandbox mode despite healthy runner

Open
#805 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, go, postgresql

Research direction

Start with agent/sandbox.go and server/conversations.go, then compare the standalone chat setup in agent/chat.go with task sandbox initialization in server/engine.go. Trace how standalone sessions obtain task identity, workspace, and scope metadata before ExecInSandbox() runs. Done means Bash executes through the required sandbox in a standalone conversation and coverage verifies the behavior.

Written by the indexing model from the issue text.

Description

bug P2

Summary

The built-in standalone Penetration Testing agent fails to execute Bash commands when ARTEX is configured with ARTEX_SANDBOX=required, despite the Sandbox Runner being operational and reporting a healthy status.

The LLM successfully processes requests, generates structured tool calls, creates an assessment plan using TodoWrite, and attempts to execute security assessment tools.

However, command execution fails because the standalone conversation does not appear to receive the sandbox execution context required by ExecInSandbox().

The failure occurs before the sandbox runner client is invoked.


Environment

Component | Version / Configuration -- | -- ARTEX | v0.7.1-2-g613ae14 Git commit | 613ae14b618dca409b1d84e781c285c8cedc5cb0 Git branch | main Operating system | Kali Linux Container runtime | Native Docker Engine Docker Engine | 28.5.2 Docker Compose | 2.40.3 LLM provider | Local Ollama LLM model | qwen3.5-artex:32k Model architecture | Qwen 3.5, 9B Quantization | Q4_K_M Context window | 32768 tokens Sandbox mode | required ARTEX backend | Running Sandbox Runner | Running / Healthy PostgreSQL | Running / Healthy Agent | Built-in Penetration Testing Execution mode | Standalone Chat / Single-agent

Ollama logs also show successful context processing without truncation in the observed completed requests:

n_ctx_slot = 32768
truncated = 0

The LLM Recording interface displays - in the Task and Worker columns for the standalone conversation.

This is consistent with the conversation not being associated with the normal task execution workflow, although those UI fields alone do not establish the internal sandbox context state.

The successful TodoWrite invocation and subsequent Bash tool invocation demonstrate that structured tool calling is functional in the observed standalone session.


Source-code analysis

The following source-code references were collected from the local repository at commit:

613ae14b618dca409b1d84e781c285c8cedc5cb0
Evidence 6 — Sandbox execution requires task-specific context

File: agent/sandbox.go

Relevant lines: 89–104.

func ExecInSandbox(ctx context.Context, argv []string, workingDir string, timeoutMS int, env []string) (sandbox.ExecResponse, error) {
    ex := activeSandboxExecutor.Load()
    if ex == nil || ex.Mode != sandbox.ModeRequired {
        return sandbox.ExecResponse{}, errors.New("sandbox executor not in required mode")
    }
    info, ok := SandboxRunInfoFromContext(ctx)
    if !ok || info.TaskID == "" {
        return sandbox.ExecResponse{}, fmt.Errorf("%w: missing task sandbox context (no local fallback)", sandbox.ErrRunnerUnavailable)
    }
    if ex.Runner == nil {
        err := fmt.Errorf("%w: runner client is not configured", sandbox.ErrRunnerUnavailable)
        if ex.OnUnavailable != nil {
            ex.OnUnavailable(info.TaskID, err)
        }
        return sandbox.ExecResponse{}, err
    }

The executor requires both:

  • Valid SandboxRunInfo attached to the context.

  • A non-empty TaskID.

The observed error originates from the context validation check.

This check occurs before the runner client is invoked.

Consequently, the error does not establish that the runner service is unreachable.

Source reference:

https://github.com/BaaRai/ARTEX/blob/613ae14b618dca409b1d84e781c285c8cedc5cb0/agent/sandbox.go#L89-L104


Evidence 7 — Runner invocation occurs after context validation

File: agent/sandbox.go

Relevant lines: 105–113.

req := sandbox.ExecRequest{
    Argv:         argv,
    Workdir:      containerWorkdir(info.TaskDir, workingDir),
    TimeoutMS:    timeoutMS,
    Env:          sandbox.FilterPanelEnv(env),
    ScopeDomains: info.ScopeDomains,
    ScopeCIDRs:   info.ScopeCIDRs,
}

resp, err := ex.Runner.Exec(ctx, info.TaskID, req)

The runner invocation depends on metadata obtained from the sandbox context.

This includes:

  • Task identity.

  • Workspace directory.

  • Authorized domain scope.

  • Authorized CIDR scope.

Without valid sandbox metadata, execution cannot safely proceed.

Source reference:

https://github.com/BaaRai/ARTEX/blob/613ae14b618dca409b1d84e781c285c8cedc5cb0/agent/sandbox.go#L105-L113


Evidence 8 — Standalone conversation execution path

File: server/conversations.go

Relevant lines: 592–600.

// Approval scope of this turn's tool calls for the target gate (chat and retester).
// The conversation's opt-in flag is the one read when the turn started: a
// switch through the API applies from the next turn.
gate := c.TargetGate
gctx := intercept.WithTargetScope(ctx, intercept.TargetScope{ConversationID: c.ID, Enabled: func() bool { return gate },
WaitBound: intercept.DefaultTargetWaitBound, Interceptor: s.m.interceptor})

// On a manual stop ctx is cancelled; Chat already emits a clean "stopped by the user"
// step, so skip the raw-error entry — only surface genuine failures.
if _, err := ca.Chat(gctx, c.AgentKey, sessionID, msg, maxTurns, maxDuration, webSearch, emit); err != nil {

The standalone conversation initializes its target approval context through intercept.WithTargetScope().

However, no equivalent initialization of SandboxRunInfo is visible in the inspected execution path before ca.Chat() is invoked.

Target approval context and sandbox execution context are distinct mechanisms.

Source reference:

https://github.com/BaaRai/ARTEX/blob/613ae14b618dca409b1d84e781c285c8cedc5cb0/server/conversations.go#L592-L610


Evidence 9 — Chat agent initializes session-level metadata

File: agent/chat.go

Relevant lines: 183–201.

// Isolates file writes across conversations, mirroring how workers use i<intentID>/.
sessionWorkDir := filepath.Join(c.workDir, "sessions", sessionID)
if !sessionDirInside(c.workDir, sessionWorkDir) {
return "", fmt.Errorf("invalid session id %q", sessionID)
}
// A run directory like the task ones, created the same way (makeRunDir).
makeRunDir(c.workDir, sessionWorkDir)
ctx = intercept.WithReviewWorkingDirectory(ctx, sessionWorkDir)

// Execution chat agents start with DefaultTools + WebFetch; orchestration
// agents (auto) receive only the orchestration/domain tools wired by
// AugmentTools / ToolResolve.
ctx = WithRunInfo(ctx, RunInfo{SessionID: sessionID})
tools, def, cleanup := assembleChatTools(ctx, agentKey, c.workDir, c.proxyAddr, c.proxyCACert)
defer cleanup()

var bashEnv []string
if !isOrchestrationChatAgent(agentKey) {
bashEnv = proxyEnv(c.proxyAddr, c.proxyCACert)
}

The Chat agent creates a session-specific working directory and initializes session-level RunInfo.

However, session-level RunInfo does not appear to satisfy the task-specific SandboxRunInfo requirement enforced by ExecInSandbox().

Source reference:

https://github.com/BaaRai/ARTEX/blob/613ae14b618dca409b1d84e781c285c8cedc5cb0/agent/chat.go#L183-L207


Evidence 10 — Task execution explicitly initializes sandbox context

File: server/engine.go

Relevant lines: 211–220.

func (e *Engine) withTaskSandbox(ctx context.Context, taskID string) context.Context {
if e.sandboxMode != sandbox.ModeRequired {
return ctx
}
var pg *db.DB
if e.m != nil {
pg = e.m.pg
}
return agent.WithSandboxRunInfo(ctx, taskSandboxRunInfo(pg, e.sandboxDataDir, taskID))
}

Unlike the inspected standalone conversation path, the task engine explicitly attaches sandbox execution metadata.

Source reference:

https://github.com/BaaRai/ARTEX/blob/613ae14b618dca409b1d84e781c285c8cedc5cb0/server/engine.go#L211-L220


Evidence 11 — Planner sandbox initialization

File: server/engine.go

Relevant line: 1185.

pctx := e.withTaskSandbox(e.budgetRoundCtx(e.plannerGateContext(ectx, t, intercept.DefaultTargetWaitBound), t, false), t.ID)

The Planner receives an explicitly initialized task sandbox context before execution.

Source reference:

https://github.com/BaaRai/ARTEX/blob/613ae14b618dca409b1d84e781c285c8cedc5cb0/server/engine.go#L1185


Evidence 12 — Worker sandbox initialization

File: server/engine.go

Relevant lines: 1435–1437.

workCtx = intercept.WithTaskContext(workCtx, t.ID, label, taskEmit)
workCtx = intercept.WithTargetScope(workCtx, t.targetScope(intercept.DefaultTargetWaitBound))
workCtx = e.withTaskSandbox(workCtx, t.ID)

The Worker receives task identity, target authorization scope, and sandbox execution context.

Source reference:

https://github.com/BaaRai/ARTEX/blob/613ae14b618dca409b1d84e781c285c8cedc5cb0/server/engine.go#L1435-L1437


Execution-path comparison

Task-based execution
Task Engine
|
+-- Task identity
|
+-- Target authorization scope
|
+-- withTaskSandbox()
|
+-- WithSandboxRunInfo()
|
+-- ExecInSandbox()
|
+-- Sandbox Runner
Observed standalone Chat execution
Standalone Chat
|
+-- Conversation identity
|
+-- Target approval context
|
+-- Session-level RunInfo
|
+-- Bash tool invocation
|
+-- ExecInSandbox()
|
+-- Missing task sandbox context
|
+-- FAIL CLOSED

The task-based path explicitly provides the sandbox metadata required by the executor.

The inspected standalone Chat path does not appear to provide equivalent metadata.


Suspected root cause

The standalone Penetration Testing agent appears to expose execution-capable tools without initializing the sandbox execution context required by those tools when required sandbox mode is enabled.

The resulting execution failure is classified as ErrRunnerUnavailable, although the observed failure is caused by missing context rather than an established runner connectivity problem.

The source-code analysis and runtime error are consistent with a missing integration between standalone conversations and the task-oriented sandbox execution lifecycle.

Maintainer confirmation is requested regarding whether this is an implementation defect or an intentional architectural limitation.


Expected behavior

Execution-capable standalone agents should support one of the following behaviors.

Option A — Secure standalone sandbox execution

Provide standalone conversations with an appropriately isolated sandbox execution lifecycle.

The implementation should preserve:

  • Explicit execution identity.

  • Conversation-specific workspace isolation.

  • Operator-approved target scope.

  • Default-deny network egress.

  • Domain and CIDR authorization.

  • Existing target approval mechanisms.

  • Restricted container privileges.

  • Execution auditing.

  • Cancellation and kill-switch behavior.

  • Sandbox cleanup.

  • Fail-closed execution.

  • No unrestricted local execution fallback.

Option B — Explicit unsupported-mode handling

If standalone execution is intentionally unsupported in required sandbox mode:

  • Clearly indicate this limitation in the Chat interface.

  • Prevent execution-capable tools from being advertised as available when they cannot execute.

  • Return a specific and actionable error.

  • Direct the operator to a supported execution workflow.


Error reporting improvement

The current error combines runner unavailability with missing execution context:

sandbox runner unavailable:
missing task sandbox context

These conditions represent different failure categories.

A missing execution context should ideally be distinguishable from:

  • Runner service unavailable.

  • Runner connectivity failure.

  • Runner authentication failure.

  • Sandbox provisioning failure.

  • Missing or invalid execution context.

  • Missing or invalid execution scope.

This would significantly improve troubleshooting and prevent unnecessary investigation of a healthy Docker or runner installation.


Security considerations

The existing fail-closed behavior is correct and must be preserved.

This issue is not requesting:

  • Disabling ARTEX_SANDBOX=required.

  • Enabling unrestricted local execution.

  • Bypassing operator approval.

  • Bypassing target authorization.

  • Reusing another task's sandbox identity.

  • Removing network isolation.

  • Relaxing container security restrictions.

The requested improvement is secure integration of standalone execution-capable agents with the sandbox architecture, or explicit handling of unsupported execution modes.


Suggested regression coverage

A regression test should exercise the standalone conversation execution path with required sandbox mode enabled.

Suggested acceptance criteria:

  1. A standalone execution-capable agent receives valid, isolated execution metadata, if this mode is supported.

  2. A harmless command can execute inside the appropriate sandbox.

  3. Missing or invalid execution context is rejected.

  4. Unauthorized network destinations remain inaccessible.

  5. Separate conversations cannot access each other's workspaces.

  6. Cancellation terminates active execution.

  7. Conversation sandbox resources are cleaned up correctly.

  8. No unrestricted local fallback occurs.

  9. Existing Planner and Worker sandbox behavior remains unchanged.

  10. Unsupported execution modes produce an explicit error rather than a misleading runner-unavailable message.

  11. Operator-approved scope remains enforced throughout the conversation lifecycle.

  12. Execution failures are recorded accurately and do not result in fabricated assessment outcomes.


Impact

In the observed configuration, the built-in standalone Penetration Testing agent can plan an assessment and generate structured tool calls but cannot execute Bash-based assessment tools.

This prevents the agent from completing its operational assessment workflow.

The agent can continue consuming LLM resources while attempting alternative execution strategies that encounter the same missing-context failure.

The resulting limitations include:

  • Inability to perform actual network discovery.

  • Inability to collect command-based assessment evidence.

  • Inability to verify observations through execution-capable tools.

  • Inability to complete the autonomous assessment workflow.

  • Unnecessary LLM resource consumption during repeated execution attempts.

  • Potentially misleading diagnostics concerning runner availability.

This issue is particularly relevant for deployments using local LLMs and mandatory sandbox isolation.


Local modifications disclosure

For transparency, the tested installation is based on upstream commit:

613ae14b618dca409b1d84e781c285c8cedc5cb0

The installation contains three local corrections addressing previously observed issues:

  1. add_intent schema and asset-anchor validation.

  2. Frontend support for rerunning exhausted or stopped intents.

  3. Sandbox worker cleanup during deletion.

The working tree contains the following modified files:

M agent/tools.go
M db/exploration.go
M sandbox/docker.go
M web/src/app/(main)/function/tasks/detail/_tabs/overview-tab.tsx
M web/src/i18n/locales/tr.json
M web/src/i18n/locales/vi.json
M web/src/i18n/locales/zh-CN.json

Additional local regression tests:

?? agent/intent_anchor_regression_test.go
?? agent/intent_validation_test.go

The files directly referenced in the suspected missing-context execution path are not listed as locally modified:

agent/sandbox.go
agent/chat.go
server/conversations.go
server/engine.go

Reproduction on a completely unmodified upstream installation has not yet been performed.

The local modifications are disclosed to avoid presenting this result as an independently verified clean-upstream reproduction.


Evidence integrity

The diagnostic evidence was saved as:

ARTEX_CHAT_SANDBOX_EVIDENCE.txt

A SHA-256 integrity manifest was generated:

SHA256SUMS

Integrity verification result:

ARTEX_CHAT_SANDBOX_EVIDENCE.txt: OK

The diagnostic report contains runtime observations, service status, sandbox configuration, source-code references, and relevant execution-path excerpts.

The diagnostic report and integrity manifest are included in the evidence package.


Questions for maintainers

  1. Is the standalone Penetration Testing agent intended to support Bash execution when ARTEX_SANDBOX=required?

  2. Is the absence of sandbox execution context in standalone conversations a known limitation or an integration defect?

  3. Should standalone conversations have their own isolated sandbox lifecycle?

  4. Is there an existing supported configuration that enables standalone sandbox execution without weakening security controls?

  5. Can missing sandbox context be reported separately from actual runner unavailability?

  6. Would a regression test covering standalone Chat execution in required sandbox mode be appropriate?

  7. Should execution-capable tools be automatically disabled in standalone conversations when the required execution context cannot be established?

  8. Should the Chat interface explicitly indicate whether the selected agent supports sandboxed command execution?


Attachments

  • ARTEX_CHAT_SANDBOX_EVIDENCE.txt — runtime diagnostics and source-code references.

  • SHA256SUMS — evidence integrity manifest.

  • Screenshot 1 — Bash execution failure showing missing task sandbox context.

  • Screenshot 2 — Successful structured TodoWrite execution.

  • Screenshot 3 — Successful LLM requests in LLM Recording.


Conclusion

The observed standalone Penetration Testing session demonstrates successful LLM communication, initial autonomous planning, and structured tool invocation.

However, the assessment cannot proceed to actual command execution because the sandbox executor rejects requests that lack the required task-specific execution context.

The runtime observations and source-code analysis indicate a potential integration gap between standalone conversation execution and the task-oriented sandbox architecture.

The existing fail-closed security behavior should remain unchanged.

Thank you for maintaining ARTEX.

This report is intended to provide actionable technical evidence of an operational limitation observed during controlled testing.

The objective is to help improve ARTEX's autonomous execution capabilities, reliability, and error reporting while preserving its existing security architecture and mandatory sandbox isolation.

I hope the technical analysis, runtime evidence, and suggested regression coverage provided in this report will be useful for implementing a secure and reliable solution and supporting the continued development of ARTEX.

Thank you for your time, dedication, and continued efforts to improve the project.

Dominant language
Go
Stars
18.7k
Forks
7k
Avg merge
10h 57m
Merged PRs (30d)
494

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from BaaRai/ARTEX

All issues in BaaRai/ARTEX

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.