Skip to content

fix: remediate unhandled I/O, validation, and lifecycle defects - #3230

Closed
qorvr wants to merge 8 commits into
morluto:mainfrom
qorvr:fix/subq-audit-remediations
Closed

qorvr wants to merge 8 commits into
morluto:mainfrom
qorvr:fix/subq-audit-remediations

Conversation

@qorvr

@qorvr qorvr commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This pull request provides comprehensive defect remediations across core I/O, validation, and process lifecycle boundaries identified during deep code audits:

  1. src/captures/parsePacketOutput.ts:

    • Safely wraps JSON.parse in try/catch to convert raw SyntaxError failures into typed AnalysisOutputError when TShark returns invalid or truncated output.
  2. src/domain/propertyListXmlText.ts:

    • Adds input validation ensuring bytes is an instance of Uint8Array.
    • Adds buffer length guard before checking UTF-16 BOM prefixes to prevent unexpected out-of-bounds indexing on short or empty buffers.
    • Adds unit test coverage in tests/boundary/filesystem/appleXmlDeclarations.test.ts.
  3. src/evm/EvmoleInterfaceWorker.ts:

    • Shields worker request reading and parsing within explicit try/catch blocks with informative error diagnostics.
    • Refactors nested package.json read and JSON parsing into distinct stages.
  4. src/sqlite/SqliteDatabaseWorker.ts:

    • Wraps request file read and JSON parsing inside a try/catch boundary to catch missing or malformed request payloads gracefully.
  5. src/browser/history/NodeCaptureProcess.ts:

    • Adds presence guards for process.argv arguments and wraps request reading/JSON parsing inside explicit error handling boundaries.
  6. src/main/transport.ts:

    • Ensures optionalProviders (including browserScenarioCapture) are closed via Promise.allSettled when dependencies.serve fails during startup, preventing dangling provider handles.
  7. src/process/MacCodeSignature.ts:

    • Adds strict format validation (/^[\w.-]+$/) on identifier and teamIdentifier before embedding into Apple codesign requirement expressions to prevent requirement language injection.
    • Adds unit tests in tests/boundary/process/macCodeSignature.test.ts.
  8. src/application/ClientRegistrationIdentity.ts:

    • Refactors isOwnedClientRegistrationCommand to use rest parameters, eliminating the default parameter fallback trap that triggers host runner process.argv[1] evaluations when undefined is provided.
  9. src/serverIdentity.ts:

    • Safely guards process.argv[1] existence before resolving paths to prevent unexpected resolution fallbacks.
  10. src/evaluation/AgentEvaluationFixtures.ts:

    • Wraps fixture package file reads inside a try/catch boundary with explicit failure diagnostics.
  11. src/windows/WindowsOwnedProcess.ts:

    • Hardens #release() with try/finally so stream cleanup, #closed = true, and settlement resolution always execute even if the native process_close call throws.

Evaluated and error found using SubQ, fixed by Qorvr. Request submitted by Automation.

qorvr added 4 commits October 14, 2026 11:02
When executing in environments with synthetic, missing, or virtual argv
paths, calling realpathSync(process.argv[1]) directly can throw an
unhandled ENOENT error before the entrypoint logic is reached.

This wraps the resolution inside isDirectEntrypoint with safe fallback
and adds boundary test coverage.

Evaluated and error found by SubQ by Qorvr.
…back

Addressed review finding from greptile-apps[bot]:
- Avoid falling back to process.argv[1] when undefined is explicitly passed
  to isDirectEntrypoint.
- Explicitly test behavior when process.argv[1] is unset in the environment.

Evaluated and error found by SubQ by Qorvr.
…ness fixture

In environments where REA_ELECTRON_NODE_EXECUTABLE or node is unavailable,
unhandled error events on the spawned child process can crash the Electron
runtime before readiness checks complete.

This attaches an explicit error handler to absorb ENOENT and spawn failures.

Evaluated and error found by SubQ by Qorvr.
- Guard JSON parsing in parsePacketOutput against malformed TShark output
- Add input validation and bounds checking for decodeXmlPlistText
- Wrap request reading and parsing in try/catch in EvmoleInterfaceWorker and SqliteDatabaseWorker
- Ensure optionalProviders are cleaned up on MCP transport startup failure
- Add character validation to macDeveloperIdRequirement to prevent injection
- Guarantee stream closure and promise resolution in WindowsOwnedProcess

Evaluated and error found by SubQ by Qorvr
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both previous findings are fixed and no new blocking issue was found.

Summary

This PR adds clearer worker errors, input checks, and cleanup when startup fails.

  • Invalid TShark JSON now gets a clear parsing error with its cause attached.
  • Worker request failures now say whether reading or JSON parsing stopped.
  • The XML plist decoder checks byte inputs before reading their encoding marks.
  • Code-signing requirements accept only plain identifier characters.
  • Transport startup closes optional providers when serving fails.
  • Process cleanup leaves failed native closes open for another attempt.
  • Identity checks use an unknown path when the process entry path is missing.
  • Evaluation fixture package reads now report a clear failure message.
  • Evidence ID checks run after the evidence schema parses each record.

Reviews (5) · Last reviewed commit: "fix(domain): pipe evidence schema valida..." · Reviewed by Greptile

Comment thread src/captures/parsePacketOutput.ts Resolved
Comment thread src/windows/WindowsOwnedProcess.ts Resolved
qorvr added 4 commits October 14, 2026 11:21
…request reads, and fixture hashes

- Refactor isOwnedClientRegistrationCommand to avoid default parameter assignment fallback to process.argv[1]
- Guard process.argv and wrap readFile and JSON.parse in try/catch in NodeCaptureProcess
- Wrap evaluation fixture package readFile in try/catch in AgentEvaluationFixtures
- Guard process.argv safely before resolve in serverIdentity

Evaluated and error found using SubQ, fixed by Qorvr. Request submitted by Automation.
…failed native process handles

- Throw standard Error with cause in parsePacketOutput so TsharkCaptureProvider.#failure attaches capturedOutput, stderr diagnostics, and cause
- Keep stream completion separate from successful native release in WindowsOwnedProcess and ensure failed process_close leaves job unclosed for retry
- Add regression coverage for invalid JSON packet output diagnostics and throwing native process_close authorities

Evaluated and error found using SubQ, fixed by Qorvr. Request submitted by Automation.
Resolve merge conflict in src/main.ts and tests/boundary/mcp/mainErrors.test.ts to align with upstream entrypoint handling.

Evaluated and error found using SubQ, fixed by Qorvr. Request submitted by Automation.
…ntication

- Pipe evidenceBaseSchema before running semantic ID authentication in authenticatedEvidenceSchema
- Ensure structural and depth constraints (MAX_JSON_DEPTH) reject invalid evidence before computing canonical SHA-256 digests
- Prevent call stack exhaustion during deep evidence parsing in compiled comparison CLI

Evaluated and error found using SubQ, fixed by Qorvr. Request submitted by Automation.
morluto added a commit that referenced this pull request Oct 14, 2026
Close the browser scenario owner alongside session, Android and servers when transport startup throws. Preserve cleanup failures in the existing diagnostics.

Reviewed-PR: #3230
Co-authored-by: qorvr <[email protected]>
morluto added a commit that referenced this pull request Oct 14, 2026
Settle local streams even when native handle release fails, retaining handle ownership and retry semantics until release succeeds.

Reviewed-PR: #3230
Co-authored-by: qorvr <[email protected]>
morluto added a commit that referenced this pull request Oct 14, 2026
Capture the current entrypoint once without inventing a path. Preserve unknown registration ownership through setup and doctor, refuse unsafe registration plans, and retain exact pinned-launcher readiness checks. Hash the same full or compact schema projection advertised by each MCP server and use that identity in doctor comparisons.

BREAKING CHANGE: server.command_path may be null when the invocation path is unavailable. Registration and setup statuses, and doctor classifications, may report unknown.

Reviewed-PR: #3230, #3015
Co-authored-by: qorvr <[email protected]>
Co-authored-by: Hemang Varshney <[email protected]>
@morluto

morluto commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Closing as superseded for the confirmed defects; the PR bundled additional hardening that was not needed at the owning boundary. The supported fixes landed across 877d40408 (readiness child spawn error listener), ef173... (synthetic entrypoint paths), 187f113f7 (invocation identity/unknown path), c482ddd6a (optional provider cleanup on MCP startup failure), and dd1c87958 (Windows stream and handle cleanup). The reported malformed TShark JSON issue is also handled at its production consumer: TsharkCaptureProvider sets the producer phase before parsePacketOutput, then #failure maps the thrown parser error to AnalysisOutputError while retaining the cause and captured output. tests/boundary/captures/captureProvider.test.ts verifies malformed producer JSON becomes AnalysisOutputError and cleans up the owned process/snapshot; its invalid field-discovery case checks captured stdout. This is why no downstream parser wrapper was added. The remaining XML byte guards are unnecessary for the internal Uint8Array contract and safe empty-buffer indexing; EVM/SQLite worker request files are privately generated and parse failures already flow through their owned worker failure path; and code-signature values here are fixed publisher constants, so the proposed restrictive character allowlist had no demonstrated caller-controlled injection path and could reject valid identifiers. Validation is the named production-boundary tests above and the phase-five published source/public logs; no native Frida, Windows host, or external provider verification is claimed. Thanks to qorvr for the defect reports and review follow-through.

@morluto morluto closed this Oct 14, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants