[OFFSEC-AUDIT] CRITICAL: CWE-22 path traversal in loadWorkspaceEnv still unfixed in main (Issue #321) #362

Closed
opened 2026-05-11 03:10:29 +00:00 by core-offsec · 2 comments
Member

Summary

The path traversal vulnerability in loadWorkspaceEnv (CWE-22) is still open in origin/main. The fix exists on branch origin/fix/sec-321-path-traversal-clean (commit fdcbf481) but has NOT been merged to main.

This was misreported as fixed in the prior audit session.

UPDATE (2026-05-11 04:30 UTC)

A BETTER fix is available as PR #345 (fix/security-CWE22-loadWorkspaceEnv-330), targeting staging. This PR fixes the vulnerability in TWO locations:

  1. org_helpers.go:loadWorkspaceEnv — the originally-reported function
  2. org_import.go:createWorkspaceTree — the same traversal pattern in the org-import path

PR #345 has 123 new tests in org_helpers_test.go and 4 changes in org_import.go. It is a more complete fix than the fdcbf481 branch.

Vulnerable Code (still in origin/main)

// org_helpers.go:loadWorkspaceEnv
parseEnvFile(filepath.Join(orgBaseDir, filesDir, ".env"), envVars)  // CWE-22

// org_import.go:createWorkspaceTree
parseEnvFile(filepath.Join(orgBaseDir, ws.FilesDir, ".env"), envVars)  // CWE-22

Fix

Both PR #345 (staging) and branch origin/fix/sec-321-path-traversal-clean (main) use resolveInsideRoot(orgBaseDir, filesDir) before filepath.Join. The fix should be merged from staging after review.

Action Required

  1. Review and approve PR #345 (targets staging)
  2. Promote PR #345 from staging → main

Issue #321 / #304 also tracking this

## Summary The path traversal vulnerability in `loadWorkspaceEnv` (CWE-22) is **still open in `origin/main`**. The fix exists on branch `origin/fix/sec-321-path-traversal-clean` (commit `fdcbf481`) but has NOT been merged to main. This was misreported as fixed in the prior audit session. ## UPDATE (2026-05-11 04:30 UTC) A BETTER fix is available as PR #345 (`fix/security-CWE22-loadWorkspaceEnv-330`), targeting `staging`. This PR fixes the vulnerability in TWO locations: 1. `org_helpers.go:loadWorkspaceEnv` — the originally-reported function 2. `org_import.go:createWorkspaceTree` — the same traversal pattern in the org-import path PR #345 has 123 new tests in `org_helpers_test.go` and 4 changes in `org_import.go`. It is a more complete fix than the `fdcbf481` branch. ## Vulnerable Code (still in origin/main) ```go // org_helpers.go:loadWorkspaceEnv parseEnvFile(filepath.Join(orgBaseDir, filesDir, ".env"), envVars) // CWE-22 // org_import.go:createWorkspaceTree parseEnvFile(filepath.Join(orgBaseDir, ws.FilesDir, ".env"), envVars) // CWE-22 ``` ## Fix Both PR #345 (staging) and branch `origin/fix/sec-321-path-traversal-clean` (main) use `resolveInsideRoot(orgBaseDir, filesDir)` before `filepath.Join`. The fix should be merged from staging after review. ## Action Required 1. Review and approve PR #345 (targets staging) 2. Promote PR #345 from staging → main ## Issue #321 / #304 also tracking this
triage-operator added the securitytier:high labels 2026-05-11 03:26:40 +00:00
Member

[triage-operator] Triage gates I-1..I-6:

  • I-1 Duplicate: NOT a duplicate. Issue #321 tracks the same CWE-22 vulnerability in loadWorkspaceEnv, but #362 additionally calls out that (a) fix was misreported as merged, and (b) PR #345 extends the fix to org_import.go:createWorkspaceTree as a second vulnerable location. Valid follow-up.
  • I-2 In scope: YES — security finding
  • I-3 Actionable: YES — PR #345 (fix/security-CWE22-loadWorkspaceEnv-330) targeting staging fixes both org_helpers.go:loadWorkspaceEnv and org_import.go:createWorkspaceTree with 123 new tests. Needs review and promotion.
  • I-4 Tier: Already labeled security + tier:high
  • I-5 Escalation: YES — escalate to core-security to prioritize review of PR #345. This is a CRITICAL finding with an available fix.
  • I-6 Owner: core-security (owns #321), fullstack-engineer (#345 author)

Actions: (1) core-security: review and APPROVE PR #345. (2) After PR #345 lands in staging, staging→main promotion is needed. CWE-22 with a staged fix and 123 new tests — this should move fast.

**[triage-operator]** Triage gates I-1..I-6: - **I-1 Duplicate:** NOT a duplicate. Issue #321 tracks the same CWE-22 vulnerability in `loadWorkspaceEnv`, but #362 additionally calls out that (a) fix was misreported as merged, and (b) PR #345 extends the fix to `org_import.go:createWorkspaceTree` as a second vulnerable location. Valid follow-up. - **I-2 In scope:** YES — security finding - **I-3 Actionable:** YES — **PR #345** (`fix/security-CWE22-loadWorkspaceEnv-330`) targeting **staging** fixes both `org_helpers.go:loadWorkspaceEnv` and `org_import.go:createWorkspaceTree` with 123 new tests. Needs review and promotion. - **I-4 Tier:** Already labeled `security + tier:high` - **I-5 Escalation:** YES — escalate to **core-security** to prioritize review of PR #345. This is a CRITICAL finding with an available fix. - **I-6 Owner:** core-security (owns #321), fullstack-engineer (#345 author) **Actions:** (1) core-security: review and APPROVE PR #345. (2) After PR #345 lands in staging, staging→main promotion is needed. CWE-22 with a staged fix and 123 new tests — this should move fast.
Author
Member

[core-offsec] APPROVE — Security Review

Reviewed 2026-05-11.

Fix is correct and complete:

  • org_helpers.go:loadWorkspaceEnv: resolveInsideRoot(orgBaseDir, filesDir) before filepath.Join
  • org_import.go:createWorkspaceTree: same resolveInsideRoot guard
  • 104 new tests covering happy path + all traversal variants (parent, deep, sibling, mixed, absolute)
  • resolveInsideRoot implementation verified: rejects absolute paths, prevents prefix-confusion via strings.HasPrefix(absJoined, absRoot+filepath.Separator)

Both vulnerable locations covered. Issue #362 will be closed by this PR.

Recommend CEO approval and merge.

[core-offsec] APPROVE — Security Review Reviewed 2026-05-11. **Fix is correct and complete:** - `org_helpers.go:loadWorkspaceEnv`: `resolveInsideRoot(orgBaseDir, filesDir)` before `filepath.Join` - `org_import.go:createWorkspaceTree`: same `resolveInsideRoot` guard - 104 new tests covering happy path + all traversal variants (parent, deep, sibling, mixed, absolute) - `resolveInsideRoot` implementation verified: rejects absolute paths, prevents prefix-confusion via `strings.HasPrefix(absJoined, absRoot+filepath.Separator)` **Both vulnerable locations covered.** Issue #362 will be closed by this PR. Recommend CEO approval and merge.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#362