Skip to content

fix(snapshot): add integrity verification and preserve execution limits#1026

Merged
chaliy merged 1 commit intomainfrom
fix/issue-977-snapshot-integrity
Apr 2, 2026
Merged

fix(snapshot): add integrity verification and preserve execution limits#1026
chaliy merged 1 commit intomainfrom
fix/issue-977-snapshot-integrity

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 2, 2026

Summary

  • Add SHA-256 integrity digest to snapshot serialization to detect tampering
  • Tampered or truncated snapshots are rejected with a clear error message
  • Fix JS bindings from_snapshot() to accept BashOptions for re-applying limits
  • from_snapshot() now builds a properly configured instance via build_bash() then restores snapshot state, preserving execution limits

Why

Snapshots had no integrity protection — an attacker could modify serialized bytes to inject variables, tamper VFS contents, or bypass execution limits. Additionally, from_snapshot() in the JS bindings created SharedState with max_commands: None, removing all DoS protection.

Tests

  • snapshot_tampered_bytes_rejected — modified payload is rejected
  • snapshot_truncated_rejected — too-short data is rejected
  • snapshot_modified_digest_rejected — modified digest is rejected
  • restore_snapshot_preserves_limits — limits survive snapshot/restore cycle
  • All 23 snapshot tests pass

Closes #977
Closes #978

- Add SHA-256 digest to snapshot serialization to detect tampering
- Tampered or truncated snapshots are rejected with clear error
- Fix JS bindings from_snapshot() to accept BashOptions for limits
- from_snapshot() now builds a properly configured instance via
  build_bash() then restores snapshot state, preserving limits

Closes #977
Closes #978
@chaliy chaliy merged commit 2952caf into main Apr 2, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-977-snapshot-integrity branch April 2, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant