Skip to content

[spark-compete] fix: restrict operator action file paths to allowed roots - #841

Open
binance1230 wants to merge 1 commit into
vibeforge1111:mainfrom
binance1230:fix/operator-path-traversal
Open

[spark-compete] fix: restrict operator action file paths to allowed roots#841
binance1230 wants to merge 1 commit into
vibeforge1111:mainfrom
binance1230:fix/operator-path-traversal

Conversation

@binance1230

@binance1230 binance1230 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor
{
  "schema": "spark-compete-hotfix-v1",
  "event": "spark-compete-first-event",
  "submission_mode": "public_repo_pr",
  "submission_target_url": "https://github.com/vibeforge1111/spark-telegram-bot/pull/841",
  "team": {
    "name": "king",
    "members": [
      "@king1005678",
      "@AtwoodJonathan1",
      "@JaredAddison12"
    ],
    "llm_device_holder": "@king1005678",
    "device_holder_github": "binance1230",
    "github_accounts": [
      "binance1230"
    ]
  },
  "target_repo": {
    "id": "vibeforge1111/spark-telegram-bot",
    "source": "https://github.com/vibeforge1111/spark-telegram-bot",
    "owner_surface": "telegram-bot"
  },
  "issue": {
    "type": "security_concern",
    "severity": "high",
    "title": "Operator action path traversal allows writing/listing outside allowed roots",
    "actual_behavior": "Operator actions (level5_smoke write, folder list) accept arbitrary file paths with no restriction \u2014 a crafted path outside home/tmp directories allows writing or listing files in sensitive locations.",
    "expected_behavior": "Operator action file paths should be restricted to home and temp directories only. Paths outside these roots should be refused.",
    "repro_steps": [
      "1. Send a level5 smoke operator action with filePath pointing to /etc/crontab or another system path.",
      "2. Observe that the file is written outside allowed roots.",
      "3. Send a folder list operator action with folderPath pointing to /etc.",
      "4. Observe that directory contents are listed."
    ],
    "affected_workflow": "Telegram bot operator action security"
  },
  "evidence": {
    "safe_links_only": true,
    "before_after_proof": "Before: operator actions accept arbitrary file paths. After: isPathWithinAllowedRoot() resolves paths and restricts to home or temp directories; actions outside these roots are refused.",
    "links": [
      "https://github.com/vibeforge1111/spark-telegram-bot/pull/841"
    ],
    "forbidden": [
      "No raw logs, private conversations, secrets, tokens, screenshots of private chats, or archive downloads."
    ]
  },
  "proposed_fix": {
    "approach": "Add isPathWithinAllowedRoot() function that resolves paths and checks they start with home or temp directory. Both level5_smoke and folder_list actions now refuse paths outside these roots.",
    "files_expected": [
      "src/operatorActions.ts"
    ],
    "tests_or_smoke": "smoke_test: operator actions with paths outside home/tmp are refused with descriptive error message"
  },
  "pr": {
    "url": "https://github.com/vibeforge1111/spark-telegram-bot/pull/841",
    "branch": "fix/operator-path-traversal",
    "title_prefix": "[spark-compete]",
    "author_github": "binance1230",
    "body_must_include": [
      "packet",
      "team",
      "pr_author",
      "repo",
      "actual_behavior",
      "expected_behavior",
      "repro_steps",
      "before_after_proof",
      "tests_or_smoke",
      "duplicate_notes",
      "risk_notes",
      "review_claim"
    ],
    "replaces_url": "https://github.com/vibeforge1111/spark-telegram-bot/pull/88"
  },
  "review_claim": {
    "impact_claim": "high",
    "evidence_types": [
      "smoke_test",
      "redacted_conversation_excerpt"
    ],
    "duplicate_notes": "Replaces #88 (which contained stacked fixes). This PR addresses only the path traversal root cause.",
    "risk_notes": "Low risk: adds a path restriction check before existing operations. Uses Node.js built-in path.resolve() and os.homedir()/os.tmpdir(). Best-effort refusal only.",
    "review_state_requested": "pr_review"
  }
}

Operator actions (level5_smoke write, folder list) accepted arbitrary
file paths with no restriction — a crafted path outside home/tmp
directories allowed writing or listing files in sensitive locations.

Add isPathWithinAllowedRoot() that resolves paths and checks they are
within home or temp directories. Both level5_smoke and folder_list
actions now refuse paths outside these roots.
@binance1230 binance1230 changed the title fix: restrict operator action file paths to allowed roots [spark-compete] fix: restrict operator action file paths to allowed roots Jun 10, 2026
NoRegretz pushed a commit to NoRegretz/spark-telegram-bot that referenced this pull request Jul 1, 2026
vibeforge1111#841: refuse safe-operator file actions whose path falls outside the root the
feature actually targets, before any write/read/list.

Rewritten per maintainer review:
- Containment now uses path.win32.relative (+ trailing-separator handling and an
  equality short-circuit) instead of startsWith, closing the sibling-prefix
  bypass (an allowed "...\\Temp" root no longer also matches "...\\Temp-evil").
- Fixed the platform mismatch: the parser only ever emits Windows C:\\ paths, so
  the guard is pinned to the Windows roots the feature targets — AppData\\Local\\Temp
  for the level5 smoke file and the user Desktop for the folder listing — derived
  from the (shape-validated) action path. The previous os.homedir()/os.tmpdir()
  check would refuse every legit request on a POSIX server whose cwd is not under
  home/tmp. Dropped the now-unused node:os import.

harness_core: interim_until_migration — re-home this guard into the Governor on
migration.

PRs: vibeforge1111#841

Co-authored-by: binance1230 <binance1230@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant