Endo Framework

repository·master·Indexed 21 days ago

https://github.com/endojs/endo

A framework for building secure, plugin-based JavaScript systems focused on supply chain attack resistance through Hardened JavaScript and secure, distributed object-capability communication. It includes utilities for Base64 encoding (@endo/base64), cross-realm byte handling (@endo/bytes), source bundling for Agoric contracts and SwingSet vats (@endo/bundle-source), and benchmarking tools (@endo/benchmark).

Tokens
208.9K
Snippets
652
Records
933
Agent score
77%

What's inside Endo

  1. Overview of Endo Zip

    master

    Endo Zip is a specialized, modernized version of JSZip implemented entirely with ECMAScript modules. It is designed for environments requiring zero dependencies on built-in modules, making it suitable for embedding in XS binaries, bundling with Rollup, or running via node -r esm.

    Key characteristics include:

    • Security-focused: Treats file name spoofing as an integrity error and requires explicit date provision to avoid issues in locked-down environments (like constructed compartments) where the ambient Date constructor is absent.
    • Modern Data Handling: Uses TypedArrays and UTF-8 without reservation.
    • TypeScript Support: Uses TypeScript JSDoc comments for information flow verification.

    Note on Limitations: To maintain security and simplicity, this version intentionally omits several features found in standard JSZip:

    • No Zip64 support: To prevent vulnerabilities related to scanning for magic numbers in specially crafted files.
    • No variable-width archive comments: To prevent potential prefix-based attacks.
    • No INFLATE compression: Support for compression has been dropped for expedience.
    • No asynchronous mode: The non-concurrent async mode from JSZip is omitted.
    • No streaming compression: Support for streaming and data descriptors is omitted.
    • No explicit directory records: These are ignored on read and omitted on write.
    • No enumeration API: There is currently no API for enumerating the contents of the archive.
  2. Overview of the Endo CLI

    master
    The Endo CLI is a command-line interface used to manage the Endo application runner (daemon). It provides tools for controlling the lifecycle of the daemon process, allowing you to start, stop, and manage the background runner that powers Endo applications.
  3. Overview of the Endo Daemon and Controller

    master

    The endo-daemon package provides two primary components:

    1. Endo Daemon: A persistent host that manages guest programs within hardened JavaScript worker processes. It manages per-user storage and compute access.
    2. Controller: A component that manages the lifecycle of the Endo daemon.

    Communication occurs via a Unix domain socket or a named pipe associated with the user. The communication protocol uses CapTP (Capability Transport Protocol) encapsulated within netstring message envelopes. The bootstrap process provides a user agent API, which serves as the foundation for deriving facets for other agents.

  4. Overview of OCapN Noise

    master

    OCapN Noise provides cryptographic support for an OCapN netlayer using the Noise Protocol. It is designed for use in web browsers and Node.js environments where WebAssembly is available. It implements the XX-x25519-ChaCha20Poly1305-Blake2 protocol variant with Ed25519 signature verification.

    Key capabilities include:

    • Generating keys.
    • Performing 3-way handshakes as either an initiator or a responder.
    • Encrypting and decrypting consecutive messages between parties.

    The implementation is highly efficient, performing no heap allocations on the Rust side of the FFI boundary.

    Note: This specific repository contains the Rust/Wasm implementation. For the JavaScript bindings and a demo, use the @endo/ocapn-noise package.

  5. Overview of @endo/ocapn-noise

    master

    The @endo/ocapn-noise package provides a Noise Protocol netlayer specifically designed for @endo/ocapn. It implements the XX-x25519-ChaCha20Poly1305-Blake2 variant with Ed25519 signature verification.

    Key features include:

    • Cryptographic Proof: Each party signs their ephemeral X25519 encryption public key with their Ed25519 signing key during the handshake, proving ownership of both key pairs.
    • Performance: The underlying cryptography is implemented in Rust and compiled to WebAssembly (Wasm).
    • Transport Agnostic: While designed to work particularly well with WebSockets, the netlayer is intended to stand atop multiple transport layers to preserve message target identities across different platforms (client, server, cloud, edge).
  6. Overview of SES (Secure EcmaScript)

    master

    SES is a shim for Hardened JavaScript, designed to enable 'fearless cooperation' between mutually-suspicious code. It allows you to safely execute third-party JavaScript by running it in isolated environments called Compartments. SES is used by production systems like Agoric and MetaMask to sandbox plugins or smart contracts and mitigate supply chain attacks.

    Key features include:

    • Compartments: Separate execution contexts with their own global object and lexical scope.
    • Frozen Realm: Compartments share frozen intrinsics (like Array.prototype) so they can recognize each other's data types without compromising security.
    • Strict Mode: Enforces JavaScript strict mode to turn silent failures into errors.
    • POLA (Principle of Least Authority): Compartments start with no ambient authority (e.g., no fetch or setTimeout by default) and must be selectively endowed with specific APIs or modules.
  7. Overview of Endo

    master

    Endo is a framework designed for building powerful JavaScript plugin systems and resisting supply chain attacks. It provides tools for confinement, communication, and concurrency.

    Key capabilities include:

    • Local Integrity: Uses Hardened JavaScript (via SES) to protect applications against supply chain attacks and prototype pollution by enforcing a tamper-resistant mode of JavaScript.
    • Distributed Integrity: Extends object-oriented programming over networks using Eventual Send (a transport-agnostic abstraction for remote procedure calls) and Capability Transport Protocols (like CapTP and OCapN).
    • Plugin Security: Provides tooling for bundling and safely executing arbitrary programs within hardened platform objects.
    • Permission Management: Works alongside tools like LavaMoat to enforce the Principle of Least Authority (PoLA), ensuring components only access the resources necessary for their legitimate work.
  8. Locate Endo user files and communication sockets with @endo/where

    master

    The @endo/where package is a utility used to find the Endo user directory and the communication endpoint (Unix domain socket on Unix-like systems or Windows named pipe on Windows) for the Endo daemon.

    Path Resolution Logic

    Endo follows these conventions to locate files and sockets:

    • Unix/Linux/macOS: Attempts to use or infer XDG Base Directory Specification paths. The user directory stores per-user runtime data, including logs and application storage.
    • Windows: Falls back to native Windows conventions. Note that on Windows, Endo does not currently use separate state and cache directories, and it does not yet sync state between different home directories. Windows communication is handled via named pipes.
  9. Create a bounded-size cache with @endo/cache-map

    master

    The @endo/cache-map package provides bounded-size caches that implement WeakMap-compatible methods: has, get, set, and delete.

    Key characteristics:

    • Bounded Size: You specify a maximum size for the cache.
    • Referential Strength Control: You can control whether keys are held weakly or strongly by providing a makeMap option. By default, it behaves like a WeakMap (keys must be objects/symbols and are held weakly). Providing Map as the makeMap option allows for arbitrary keys (like strings) which will be strongly held.
    • Eviction Policy: The cache uses an internal eviction policy (such as CLOCK or SIEVE) designed to match or exceed LRU hit ratios.
    import { makeCacheMapKit } from '@endo/cache-map';
    
    // Create a cache with a capacity of 100
    const { cache, getMetrics } = makeCacheMapKit(100);
  10. Adapt Node.js streams to Endo async iterables

    master

    The stream-node package provides adapters to bridge Node.js streams with Endo's async iterable stream interface.

    • Use makeNodeReader to convert a Node.js Readable stream into an Endo-compatible async iterable reader.
    • Use makeNodeWriter to convert an Endo-compatible async iterable writer into a Node.js Writable stream.
  11. Understand the security support policy

    master

    The SES package and associated Endo packages are under active development and security review.

    • Version Support: Security fixes are only provided for the most recent branch.
    • Recommendation: Users are strongly encouraged to always use the latest available version to ensure they have the most recent security updates.
    • Response Times:
      • Acknowledgment via email is expected within one business day (subject to Pacific Time business hours).
      • Vulnerability validation may take up to 72 hours.
      • For Critical or High Severity issues, a security advisory will be released to notify impacted parties to prepare for an emergency patch.
  12. Redact error messages with @endo/errors

    master

    The @endo/errors package provides utilities to construct errors with redacted messages. This is used to prevent guest programs (or untrusted code) from accessing sensitive internal state information when a host function throws an exception.

    When used in coordination with ses (Secure EcmaScript) in the host realm, the full, unredacted error information is sent to the realm's console for debugging purposes, but remains invisible to any code that catches the error. This ensures that while developers can still debug issues, the untrusted code only sees a redacted version of the error.