Skip to content

fix(vine,filesystem): remove unconditional RegisterOperation leak; fix WriteFile byte-array decode and Stat path ordering#72

Merged
NikolaRHristov merged 1 commit into
Currentfrom
fix/vine-filesystem-issues-63-65
Jun 4, 2026
Merged

fix(vine,filesystem): remove unconditional RegisterOperation leak; fix WriteFile byte-array decode and Stat path ordering#72
NikolaRHristov merged 1 commit into
Currentfrom
fix/vine-filesystem-issues-63-65

Conversation

@NikolaRHristov
Copy link
Copy Markdown
Member

Closes #63, #65

Issue #63 - ActiveOperations map leak

process_cocoon_request called RegisterOperation unconditionally on every RPC but no handler ever called UnregisterOperation. The ActiveOperations map grew without bound — one leaked CancellationToken per RPC. In long sessions with 14k+ RPCs this is 14k+ live entries.

Fix: Remove the unconditional RegisterOperation call from process_cocoon_request. Operations that need cancellation must opt-in by calling RegisterOperation from within their handler body and UnregisterOperation on both success and error paths. The cancel_operation path already removes the entry after token.cancel() — no change needed there.

Also removed ValidateRequest checks for "::" and "../" in method names. Path traversal is in parameters, not method names; these checks block legitimate callers and provide no security benefit.

Issue #65 - FileSystem WriteFile + empty-path guard

WriteFile byte-array decode removed:

  • Value::Array path iterated every element with v.as_u64().map(|n| n as u8) — one enum-match per byte
  • filter_map silently dropped bytes >127 from signed Int8Array serializers, causing silent data corruption
  • Now returns a clear error if an array is passed; base64 string is the only accepted encoding

Empty-path guard extracted to require_non_empty_path():

  • Replaces four copy-pasted identical guards across ReadFile, WriteFile, ReadDirectory, Stat
  • Standardizes ordering: path validated before Environment.Require() in all handlers (Stat previously validated after)

Comment added on the vscode://schemas-associations/ special-case in ReadFile.

…-array decode and Stat empty-path ordering

Closes #63, #65

Issue #63 (ActiveOperations leak):
- Remove unconditional RegisterOperation call from process_cocoon_request.
  No handler ever called UnregisterOperation, so the map grew without bound.
  Operations that need cancellation must opt-in explicitly from their handler.
- cancel_operation already removes the entry after token.cancel(); no change needed there.
- Remove ValidateRequest checks for "::" and "../" in method names per issue comment
  (path traversal is in params, not method names; these checks block legitimate callers).

Issue #65 (FileSystem):
- Remove Value::Array decode path from WriteFile. Require base64 string only.
  The filter_map over as_u64() silently drops bytes >127 from signed Int8Array
  serializers, causing silent data corruption. Return a clear error if array is passed.
- Extract require_non_empty_path() inline helper; replace the four copy-pasted
  empty-path guards across ReadFile, WriteFile, ReadDirectory, Stat.
- Standardize ordering: validate path before run_time.Environment.Require() in Stat
  (was inconsistent vs the other three handlers).
- Add comment on vscode://schemas-associations/ special-case in ReadFile.
@NikolaRHristov NikolaRHristov merged commit c035dc6 into Current Jun 4, 2026
7 of 9 checks passed
@NikolaRHristov NikolaRHristov deleted the fix/vine-filesystem-issues-63-65 branch June 4, 2026 21:16
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.

[Vine/Server] ActiveOperations map leaks CancellationTokens — UnregisterOperation never called in process_cocoon_request

1 participant