Skip to content

Fix Picoclaw runtime security contracts#16

Open
mjc wants to merge 1 commit into
mainfrom
mjc/auth-picoclaw-security
Open

Fix Picoclaw runtime security contracts#16
mjc wants to merge 1 commit into
mainfrom
mjc/auth-picoclaw-security

Conversation

@mjc

@mjc mjc commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • harden Picoclaw runtime install cache/download/archive handling and redact checksum/runtime command output
  • replace shell-form runtime start/stop/onboard execution with fixed argv helpers
  • validate Picoclaw session IDs before lock/session/filesystem use and avoid releasing unknown sessions from a header alone
  • move pure security helpers into a testable package to avoid native KVM test-link failures

Tests

  • nix develop /home/mjc/projects/NanoKVM-nix-build-env --command go test ./service/picoclaw/security
  • nix develop /home/mjc/projects/NanoKVM-nix-build-env --command go test ./service/picoclaw -run '^$'
  • nix develop /home/mjc/projects/NanoKVM-nix-build-env --command go test ./... -run '^$'

Copilot AI review requested due to automatic review settings June 7, 2026 19:19
@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@mjc, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 45 minutes. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 50f283b7-f951-4280-a874-ace21c4a1c5b

📥 Commits

Reviewing files that changed from the base of the PR and between 3de4a18 and f17f620.

📒 Files selected for processing (10)
  • server/service/picoclaw/gateway_proxy.go
  • server/service/picoclaw/runtime_constants.go
  • server/service/picoclaw/runtime_handlers.go
  • server/service/picoclaw/runtime_install.go
  • server/service/picoclaw/runtime_session.go
  • server/service/picoclaw/runtime_start_stop.go
  • server/service/picoclaw/security/security.go
  • server/service/picoclaw/security/security_test.go
  • server/service/picoclaw/session_history.go
  • server/service/picoclaw/session_manager.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mjc/auth-picoclaw-security

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.

Copilot AI 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.

Pull request overview

This PR hardens the Picoclaw service’s runtime install/start/stop pathways and session handling to better enforce security contracts (bounded downloads, safer archive extraction, redacted command output, and stricter session ID validation). It also introduces a dedicated security subpackage for reusable/testable security helpers.

Changes:

  • Add a service/picoclaw/security helper package (size-bounded streaming copy, safe tar entry filtering, session ID validation, fixed argv builder, and output redaction) plus unit tests.
  • Replace shell-form runtime script execution (sh -c) with fixed-argv execution helpers and redact runtime output / sensitive install details.
  • Validate Picoclaw session IDs before using them for locks/session lookups/filesystem access, and avoid releasing sessions solely based on a header value.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
server/service/picoclaw/session_manager.go Reject invalid session IDs at registration time.
server/service/picoclaw/session_history.go Validate session IDs for session read/delete endpoints; route validation through new security helper.
server/service/picoclaw/security/security.go New security utilities (bounded copy, safe tar entry checks, session ID validation, fixed argv, output redaction).
server/service/picoclaw/security/security_test.go Unit tests covering new security helpers.
server/service/picoclaw/runtime_start_stop.go Replace sh -c with argv-based execution and redact command output.
server/service/picoclaw/runtime_session.go Validate session IDs and avoid releasing unknown sessions from header alone.
server/service/picoclaw/runtime_install.go Harden runtime install cache perms, archive download perms, enforce max download size, safe archive extraction, and redact checksum mismatch details.
server/service/picoclaw/runtime_handlers.go Redact runtime install response fields that may expose local paths/URLs.
server/service/picoclaw/runtime_constants.go Add explicit maximum archive size constant.
server/service/picoclaw/gateway_proxy.go Validate gateway session_id query parameter before lock/session usage.

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

Comment on lines +188 to 193
output, execErr := picoclawScriptCommand(ctx, scriptPath, "onboard").CombinedOutput()
trimmedOutput := picoclawSecurity.SanitizeRuntimeOutput(output)
if execErr != nil {
if trimmedOutput == "" {
trimmedOutput = execErr.Error()
trimmedOutput = "picoclaw command failed"
}
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