Changelog
On this page
All notable changes to this project are documented here. The format follows Keep a Changelog, and the project aims to follow Semantic Versioning once it reaches 1.0.
[Unreleased]
First public version, released under the MIT license. Experimental: not yet published to Hex and not yet run against a production fleet.
Added
-
Closures held in state are reported before a deploy: the plan (
--dry-run, the preflight, every deploy) reads the states of the processes the deploy touches and reports each closure defined in a patched module as:closure_in_state(warn), with the process, how many processes share it, a path into the state (state.callbacks.0) and the closure's module.config :hotcode, block_on_closure_in_state: truemakes it a block.Hotcode.Closureswalks a term with bounds (24 levels, 20 000 terms). The struct scan's read of a state serves this check too (guide). -
Cross-node contracts: the plan reports
:cross_node_contract(warn) for every function a patch removes or adds that the app calls on other nodes with a literal module and function (:erpc,:rpc,Node.spawn,:gen_rpc), read from the compiled code (Hotcode.CrossNode) (guide). -
config :hotcode, struct_scan: [concurrency:, suspend_concurrency:, timeout_ms:, max_processes:, only:]: how many states are read and processes suspended at a time, the read timeout, a cap that refuses a larger struct scan in the plan (:struct_scan_limit, block), and a filter on the initial-call module of the processes read for a changed struct. Measured costs in Operations. -
Hotcode.Loader.modules/1: an application's modules including those hot deploys added (the.applist, whichApplication.spec/2reads, never changes). Theafter_deploy/1report carriesnew; theafter_rollback/1report carriesmodulesandunloaded. -
gen_statemhosts: the{Host, mod_key}and{Host, mod_key, state_key}entries ofhosts:read the keys from thedataof a{state_name, data}state; tested with a host whosecode_change/4forwards to the hosted module. -
Fleets that are not an Erlang cluster (
Hotcode.Fleet, guide):hotcode push patch.hcp --targets FILE|-(or--target URL[,key=value,...],--targets-cmd CMD; each target may carry free-formkey=valuemetadata) surveys every node (status and dry run; nodes already on the release are skipped, so a rerun resumes), deploys--canary Nnodes (or those whose metadata matches--canary-match KEY=VALUE), checks them (the node's status and--health-url), waits--soak, then the rest,--max-parallelat a time (group by group of a metadata key with--group-by KEY,--group-order), and past--max-failureshalts and rolls back the nodes it changed with a rollback signed by the same keys (or--rollback-file, or--no-rollback). One JSON entry per target; the exit codes keep their meaning (3 or 4: nothing changed anywhere, 5: a target failed after something changed).hotcode status --targetsreports every node. The per-node calls go throughHotcode.Fleet.Transport(Hotcode.Fleet.HTTPby default);Hotcode.Client.status/2takesscope: :local. -
Building without reaching a node:
mix hotcode.manifest --out manifest.json [--release DIR]saves what a build or an assembled release contains (Hotcode.Manifest.from_build/2: module MD5s and code digests, application versions, OTP and Elixir,MIX_ENV, release, audience,allowed_prefixes),mix hotcode.build --manifest manifest.jsonbuilds against it, andhotcode describe manifest.jsonsummarizes it. The node still checks the patch's base, OTP, audience, policy and signatures itself: a stale manifest can only make it refuse. -
store_fetch: {m, f, a}: a node without a durable disk is handed, at boot, the signed envelopes it should run (Hotcode.Store.fetch_dir/1for a directory), each verified and re-applied like a stored patch, inseqorder, merged withstore_dir. Operations guide: "Ephemeral disks and immutable images". -
Waiting for old code:
--wait-for-old-code 60sonpush,deployand the fleet push (?wait_for_old_code=MS,Hotcode.Rolloutoption:wait_for_old_code,config :hotcode, wait_for_old_code:) re-checks the processes still on a displaced version for up to that long before the preflight refuses:lingering_old_code.Hotcode.Drain(wait_for_old_code/3,lingering/1,await_children/3,await_envelope/2) forbefore_deploy/1hooks that drain aTask.Supervisoror Oban queues first. -
An agent skill in
skills/hotcode/(guide): instructions for a coding agent adopting Hotcode in a project (deployment-shape triage, audit, classification, configuration, conversions, tests, CI, first deploy, rollout), references, andscripts/audit.exs, a read-only scan of a project for hot-deploy hazards and deployment clues. -
Rolling out to a large cluster (
convergence: [mode: :spread], guide): the signed statement may carry a rollout policy ("rollout",--rollout-canary,--rollout-soak,--rollout-success,--rollout-max-unavailable,--rollout-halt-failures,--rollout-fanout,--rollout-order,--rollout-deadline,--rollout-min-canaries,--rollout-canary-match,--rollout-group-by,--require-promote), shown to co-signers asROLLOUT:lines and shape-checked byHotcode.Trust; absent, the statement is unchanged. The operator deploys to the canaries only (hotcode push --canary N,--canary-match KEY=VALUE;config :hotcode, canary: true). Nodes describe themselves with free-formconfig :hotcode, metadata:labels (Hotcode.Spread.metadata/0); Hotcode gives no key a meaning: the policy'scanarymaymatchon them, andgroup_bynames the key whose value groups the spread (a key has no[or]; an{m, f, a}has 250 ms to answer,Hotcode.Spread.Metadata). The canaries soak (canary_check, sampled) and promote themselves, or wait for a signed promote (mix hotcode.promote,Hotcode.Envelope.build_promote/1,Hotcode.Trust.verify_promote/2). Every other node pulls the release from a spreader or upgraded node (its own group first), verifies it with its own loader (which also requires the policy and the expected release), runs the health check, and rolls itself back on failure; withgroup_by, groups go one after the other or all at once, at mostmax_unavailable_pctof a group (without it, of the cluster) upgrading (:globalslot locks), a source serving at mostfanoutat once.halt_failuresfailures, or a canary missing its deadline, halt it, and a release that also carriesauto_rollbackis undone at once (the halt is the trigger;after_msstays the deadman's deadline) with the deadman's rails. The decisions are pure functions (Hotcode.Spread.Plan), run byHotcode.Spreadon each node. Telemetry[:hotcode, :spread, :canary_passed | :promoted | :infected | :failed | :halted | :done]and the audit events:spread_*. -
Spread: a push as the fallback of a pull. A node whose pulls reach no source
push_after_attemptstimes (a signed policy field,--rollout-push-after, default 3), or that may not pull (spread: [pull: false]), asks for a push; one designated source pushes it (Hotcode.Spread.accept_push/3), under the same cap, fanout, group order and halt rails, and the node verifies it as it would a pull; a refused push does not mark it failed. Audit:spread_pushed. -
Spread: a halted release can be resumed by a signed statement (
hotcode resume,mix hotcode.resume,POST /resume,Hotcode.Envelope.build_resume/1,Hotcode.Trust.verify_resume/2; threshold, audience, expiry, bound to the release, its own seq as replay counter), delivered to every node under the roll lock the undo takes. Failures before it stop counting; every failed node is retried once (one that rolled the release back after its own health gate through one armed acceptance of exactly that statement,Hotcode.Loader.allow_retry/2, the replay counter untouched); refused as:undoneonce the undo ran, and the undo, under the same lock, skips a release a resume took out of the halt. Telemetry and audit:spread_resumed. -
Spread: a node starts an upgrade only when it sees a strict majority of its group's known nodes, so a partitioned group never uses the cap twice; under the slot it reads its group's nodes directly, so a failure there is never missed whatever the backend.
-
The undo of a halted spread rolls holders back 8 at a time (
undo_concurrency) instead of one after the other (the deadman's undo is unchanged). -
Hotcode.Cluster.Members.Backend: the version table through a backend; the built-in one (Local) is the default,members_backend: :synkeeps it in a:synscope (Hotcode.Cluster.Members.Syn,:synis an optional dependency). The table also carries each node'smetadataandspreadrole. -
hotcode status TARGET --spread,hotcode wait TARGET [--done | --halted] --timeout --interval(exit 0 done, 5 halted, 6 still going when the time ran out: a new exit code, forwaitonly),hotcode promote;GET /spreadandPOST /promoteon the HTTP endpoint;?scope=canaryonPOST /deploy. -
Tests: the state machine (
spread_plan_test.exs), the policy (spread_policy_test.exs),:peercluster tests with:synand groups (cluster_spread_test.exs), and a simulation of 200 nodes in five groups with no BEAMs (spread_sim_test.exs,Hotcode.SpreadSim). -
Documentation: a shorter README, with the detail moved to three new guides: Features and support, A change, step by step and Limits.
-
Testing helpers,
Hotcode.Test.use Hotcode.Testreplacesuse ExUnit.Caseand refusesasync: true. It resets the loader and allows unsigned deploys for the test. Afterwards, even after a test that raised, it gives every replaced module its original binary back, unloads what the test hot-loaded, drops theHotcode.Tabletables it created and restores the application environment.build/2compiles the next version of some modules with an externalelixircinto aHotcode.Test.Release(not loaded until deployed; cached by a hash of the sources).deploy!/2androllback!/1wrap the loader. Assertions, whose failure messages name the hot-deploy mistake:assert_upgrades/3andassert_roundtrip/3forHotcode.Versioned(the property form takes a StreamData generator);assert_survives_deploy/3(same pid, migrated state, not left on old code, exact state after a rollback);assert_survives_redeploy/3(a second deploy; names the pids the loader refuses to purge and explains:badfun);assert_table_upgrade/3andassert_table_deploy/3forHotcode.Table;with_load/3andassert_no_lost_messages/2for traffic during a deploy; andHotcode.Test.Cluster(:peernodes with generated keys, a boot release, mixed versions, signed rolls). StreamData is a new optional dependency, needed only for the property form.Hotcode.Loader.reset/0andHotcode.Loader.pids_on_old_code/1are now documented. Guide: Testing your hot deploys. -
Deadman rollback:
convergence: [mode: :auto]and a signedauto_rollbackpolicy.mix hotcode.buildandmix hotcode.deploytake--auto-rollback-after 120s(and--auto-rollback-attempts N), which put"auto_rollback": {"after_ms": ..., "attempts": ...}in the signed statement.Hotcode.Trustchecks its shape (:bad_statementotherwise), andmix hotcode.signshows it as anAUTO-ROLLBACK:line. In:automode, when a reachable node could not follow such a release by the signed deadline (its pulls failed), one coordinator undoes that release, and only it, on every node that has it, through the newHotcode.Loader.auto_rollback/2, which checks that the stack entry carries the policy. The coordinator is the lowest node name on the head; it acts under the roll lock, with a strict majority of the cluster visible, no unreachable node on the head and nothing requiring the release. Audit:cluster_auto_rollback/:cluster_auto_rollback_failed, telemetry[:hotcode, :cluster, :auto_rollback],report().converge.state == :rolled_back. It never acts twice, never cascades, and does not retry a failure. Without a policy in the statement (the default, byte for byte as before), or in any other mode, nothing is undone automatically. Stack entries now keeprequires, the policy and when they were applied (Hotcode.Loader.status/0:head,required). -
Converging forward:
convergence: [mode: :converge]. A reachable node that is behind (its release is in the history of the one release ahead of all others) pulls the signed envelopes it lacks from a random peer'sstore_dirand deploys them through its own loader, with its own verification (threshold, audience, expiry, replay, base,requires, policy). It does not pull during a roll, while locked or locked out, across a fork (reported as[:hotcode, :cluster, :cannot_converge]) or from an unreachable node. Bounded byattempts: 3andbackoff_ms: 5_000, then[:hotcode, :cluster, :converge_failed]with the reason; an envelope past its TTL is refused as:expired. Only nodes with astore_dircan be sources. New:Hotcode.Store.stored/0,Hotcode.Store.envelope/1,Hotcode.Cluster.Members.lineage/0, andconverge:inMembers.report/0.:reportstays the default and changes nothing. -
A cluster-wide version table and a convergence report. Every node keeps a table of every node and its release (
Hotcode.Cluster.members/0), updated by announcements, node monitoring and a 10 s probe. A cluster left on two releases after a roll is reported (log, audit, telemetry[:hotcode, :cluster, :diverged]). Nothing is undone, and a roll in progress or an unreachable node is not judged. -
ETS migration,
Hotcode.Table. Versioned ETS tables (use Hotcode.Table, vsn: N): a deploy that changes what a table stores rewrites its rows throughupgrade/2steps, a rollback runs the newer module'sdowngrade/2first, and a release with a hole in the chain or no way back is refused with the table untouched. A keeper process is the tables' heir, so a table survives its owner being replaced and is taken over by the new one. -
Fixes for pitfalls found by review: the old version of a module is kept until the next deploy (a closure now survives one deploy);
Swapre-sends the casts and messages waiting in the old process's mailbox; a process too busy to answer is migrated like any struct holder instead of skipped;before_deployis not called while stored patches are re-applied at boot; new analyzer findings:removed_exportsand:build_env; five more Credo rules. -
Igniter installer.
mix igniter.install hotcode(ormix hotcode.install) adds the node'sconfig :hotcodefor:prodtoconfig/runtime.exs, Credo and the Hotcode plugin, andjasonon Elixir 1.17. It trusts no key. Igniter is an optional dependency. -
Credo rules for code that will be hot-deployed (
Hotcode.Credo.checks/0):@on_load,:erlang.load_nif/2, a closure kept in state, ETS or a message (it fails with:badfuntwo deploys later), and aHotcode.Versionedmodule with a missingupgrade/2ordowngrade/2step.mix hotcode.checkruns them with no configuration, andmix hotcode.credo.installaddsHotcode.Credo.Pluginto your.credo.exs. Guide: Credo rules. -
Credo rule
HC0011Hotcode.Credo.Check.TerminateClosesSockets: a GenServer or:gen_statemterminatethat closes a socket or port, or stops a listener, without callingHotcode.Swap.swapping?/0. During a swap it would close the connection handed to the replacement process. There are now eleven rules. -
Credo rules
HC0012toHC0017:ClosureInOptions(anfnor local capture in a child spec,start: {M, F, [fn]}, or a long-kept option:configure:,after_connect:,measurement:,tag_values:,keep:,drop:,sni_fun:,verify_fun:),LoggerLocalFilter(:loggerfilters and handler configs with closures),LocalAcceptLoop(anaccept/recvloop that calls itself locally),DeriveOutsidePrefix(@deriveof a standard-library protocol),ProcessDictionaryState(Process.putin a GenServer callback) andApplicationStartSideEffects(tables, terms and handlers set up inApplication.start/2). There are now seventeen rules.&(&1.field)is now seen as an anonymous function byHC0003andHC0005too. -
Phoenix channels and LiveViews get their
code_change/3: a deploy that changes a channel or LiveView module (found by the initial call Phoenix sets,{Mod, :join, 3}or{Mod, :mount, 3}, and the module's@behaviour) runs:sys.change_codeon its processes, which Phoenix forwards to the module with the socket as the state, and the rollback pre-flight of aHotcode.Versionedchannel or LiveView reads that socket. No configuration. Before, these processes were only suspended and struct-migrated. -
use Hotcode.Versionedpasses its other options touse GenServer(restart:,shutdown:,id:), andgen_server: falsegenerates onlycode_change/3(for a Phoenix channel or LiveView). -
use Hotcode.Versioned, vsn: 1can be added to a running module in a hot deploy: the state of the unversioned release is taken as version 1 and kept, both ways. Going from an unversioned release straight tovsn: 2or higher is still refused ({:unsupported_transition, old, new}), now with a message saying to shipvsn: 1first. -
mix hotcode.installaddsMyAppWebtoallowed_prefixesfor a:phoenixdependency too, and every other top-level namespace defined underlib/; its notice prints the list. -
Guides: reaching the node through SSH tunnels,
fly proxy, tunnel sidecars, reverse proxies, and IPv6 (getting started); the application's ownpriv/and Ecto migrations with hot deploys (limits); where Hotcode does not fit;persistent_term,Agentand memory during a migration (state migration). -
Support for Elixir 1.17 and OTP 26. The test matrix runs eight pairs from Elixir 1.17 / OTP 26 to Elixir 1.20 / OTP 29 (
.github/workflows/ci.yml; locallyscripts/matrix.exs). Hotcode reads JSON with the built-inJSONmodule from Elixir 1.18, and with the optionaljasonon 1.17, which your application then lists as a dependency. -
Deploying from CI. A toolchain image (
docker/Dockerfile, one tag per OTP and Elixir pair) with a stand-alonehotcodecommand that signs, pushes, inspects and rolls back without your project (describe,sign,push,rollback,status,gen-key). Building a patch staysmix hotcode.build, in your project. Every command takes--json(one object on stdout) and exits with a code that says what happened: 2 usage, 3 unreachable, 4 refused (nothing changed), 5 a roll that failed.--key env:NAMEreads a private key from a CI secret.mix hotcode.describeprints what an envelope authorizes. New guide Deploying from CI; workflows to test the repository and publish the image. -
Clusters.
Hotcode.Rolloutruns a dry run on every node before touching any, so a patch one node would refuse never runs on the others.--requires VERSION(signed in the statement) makes a release wait until an earlier one is live on every node.Hotcode.Cluster.applied?/1gates code that writes a new message format, withexpected_nodesfor partitions. The guide Clusters and mixed versions explains the readers-then-writers order. Tested on real multi-node clusters and on two realmix runnodes. -
Deploying.
mix hotcode.build,sign,push,deploy,rollbackandstatusbuild the smallest patch against what a live node runs, sign it, and apply it atomically with processes suspended around the switch, state migrated and everything undone on failure. -
Authorization. Default-deny nodes that hold only Ed25519 public keys. Signed envelopes bind the patch hash, audience, expiry, a replay counter equal to the issue time, the code the patch replaces and the
force/restart_appsflags.thresholdsigners, a module policy (allowed_prefixes; never OTP, the standard library or Hotcode), signed rollback, a kill switch, a failure lockout and an audit log. -
HTTP endpoint. Every request is signed over a stateless single-use challenge issued by the node and verified before any body byte is read. TLS is required off loopback.
-
State migration. Changed structs are migrated automatically;
Hotcode.Versionedhandles changes of meaning; hand-writtencode_change/3is supported; state is downgraded on rollback. -
Restart-free replacement.
Hotcode.Holder,HandoffandSwapmove a process's state and open sockets to its replacement; supervision-tree changes are applied in place;Hotcode.AppSwaprestarts one application (not the node) forApplication.start/2,@on_loadand NIF changes, behind a signed request and an operator opt-in. -
Persistence. Patches are stored as signed envelopes, re-verified and replayed at boot, with a revoked set for rolled-back patches.
-
Rolling deploys. Node-by-node rollout with a health gate and automatic undo.
-
Extension points.
Hotcode.Hookcallbacks, telemetry events,health_check. -
Dependency bumps.
Hotcode.Semverclassifies every application version change: patch and minor bumps are reported; a major bump, a0.xminor bump, a downgrade or a non-semver version is blocked unless the signers accept it (--accept-major APP, part of the signed statement). The node tracks the deployed version of each application, since a running application's.appfile cannot change. -
New NIF and
@on_loadmodules are a warning, not a block. They are loaded before the atomic batch and unloaded again if the batch fails. This is how a Rustler NIF is upgraded (a new module beside the old one, behind a facade). Only replacing a loaded one is blocked. -
Struct migration reaches every process that holds the struct, not only those of changed modules. Processes running code under
allowed_prefixesare found by inspecting their state, so LiveViews and holders of dependency structs need no configuration. -
Examples (
examples/), guides (docs/guides/), and a test suite of 521 tests and 6 doctests (withHOTCODE_REQUIRE_CLUSTER=1), including real:peernodes, TLS, live sockets, fault injection and about 40 end-to-end tests that drive real OS processes and the real mix tasks.examples/pulseruns Phoenix Channels, Ecto/Postgres, Rust NIFs, a raw TCP feed and a second OTP application under 16 live channels, 4 TCP connections and an external checker, through ten versions: struct migration, a new NIF, two refused releases, a dependency bump, a regression, a hook veto, supervision-tree changes, a process swapped through the holder, an in-place application restart signed by two people, rollbacks, and a node restart that comes back on the deployed version.
Changed
-
The struct scan tests
allowed_prefixeswith the core-module set computed once per scan, not once per process: a plan over 20 000 processes went from about 1.3 s to 0.2 s. -
The audit script of the agent skill no longer names a web framework:
francis_router_is_appis gone (an editedApplicationmodule staysapplication_callback), andfrancis_handler_closureis nowhandler_closure, any handlerfngiven to aws,sse,socket,on,subscribeorregistercall. -
Hotcode.Cluster.Members.lineage/0judges "ahead" over the distinct(version, history)pairs instead of node by node: the same answer, without a cost quadratic in the number of nodes. -
Hotcode.Loader.status/0also returnsmetadataandspread; the stack entry andheadkeep the signedrolloutpolicy;Hotcode.Loader.auto_rollback/2also acceptsmode: :spread. -
The step callback of
Hotcode.VersionedandHotcode.Tableis nowupgrade/2(wasmigrate/2);downgrade/2is unchanged. The number in a clause still names the version the state or row comes from:upgrade(1, s)goes v1 -> v2. Error reasons name it too ({:no_step, :upgrade, n},{:step_failed, :upgrade, n, message}), and the testing helpersassert_migrates/3andassert_table_migration/3are nowassert_upgrades/3andassert_table_upgrade/3. No alias is kept: rename the clauses.
Fixed (found by the cluster and distribution end-to-end tests)
- A deploy by node name from another machine started the CLI node under the target's address,
so it only worked against a node on the same host. It now uses the address the OS routes to the
target (
HOTCODE_CLI_HOSToverrides it). mix hotcode.signwithout--yescrashed instead of asking.mix hotcode.deploy NODE@HOSTcrashed: the build and the push each started Erlang distribution, and the second start failed.mix hotcode.rollback NODE@HOSTcrashed looking up the running version: distribution answers with the node name as an atom, HTTP with a string.
Fixed (found by the pulse example)
-
A release the node refused could run for a moment. The loader loaded the new code, then migrated tables and checked the
Hotcode.Versionedchains, and only then refused and put the old code back. Processes that were not suspended (Phoenix channels calling a changed module) ran the refused code in between:examples/pulsesaw 4 replies tagged with a refused release. The loader now checks tables (missingupgrade/2ordowngrade/2clause, a step that raises, avsngoing backwards) and the states of suspendedHotcode.Versionedprocesses (upgrade and downgrade chains, struct reshaping) before loading anything, by running the new modules under another name on copies (lib/hotcode/shadow.ex). Such a refusal returns the same error as before,{:table_migration_failed, info}or{:migration_failed, info}, with the new fieldloaded: false; a refusal found after loading hasloaded: trueand is undone as before. The CLI exit codes do not change. Which refusals are found before loading and which only after is listed in How it works. Works on OTP 26 to 29. A module that cannot be run under another name is checked after loading instead, with a warning logged once and the telemetry event[:hotcode, :shadow, :unavailable]. -
Hotcode.Swapdocs said a call waiting in the old mailbox is answered by the new process. It is run by the new process, but its caller monitors the old one and always exits with:shutdown, so the reply is lost and a caller that retries runs the request twice. The docs now say so and advise retrying only idempotent requests;test/swap_gap_test.exsasserts both the exit and the run, and its other:shutdown/:noprocassertion is now exact. -
Docs:
Hotcode.Swap.swapping?/0is never set byHotcode.AppSwap, whose handed-over workers are killed (theirterminate/2does not run) while the others stop normally. -
Hotcode.Hook: hooks were skipped under interactive code loading (mix run, dev). A hook module that nothing had called yet was not loaded,function_exported?/3returned false, and thebefore_deployveto and every notification were ignored. Hook modules are now loaded before they are called. -
Processes running a changed module's code without it being their callback module (a Phoenix channel reports
{MyChannel, :join, 3}and runs insidePhoenix.Channel.Server) were not suspended across the switch, so a request handled at that moment could run half on the old code and half on the new (examples/pulsesaw one reply tagged v3 in the v2 format). They are now suspended too, when they answer:sys. -
Hotcode.Versioned: a rollback between two releases with the samevsn(only the code changed) failed with:unsupported_transition, and the loader killed the process. It is now a no-op for the state. -
Rollback of a supervisor whose child spec changed: the supervisor re-read its
init/1while the new code was still loaded, so it kept the new spec and the child was not put back. Supervisors now re-read their children after the old code is loaded again (also when a failed deploy is undone). -
Hotcode.Store: a patch re-applied at boot had no sequence number, so rolling it back after that boot did not revoke it, and a copy of its file put back in the store returned at the next boot. -
The analyzer said a changed supervisor's "running children are not started or stopped", which is wrong with the default
supervision: :auto. It now says they are reconciled.
Fixed (found by the ten_versions and live_edge examples)
- A module that an earlier patch added is now attributed to its application on the node, so a later patch can remove it. Patches carry the owner of every module they ship, and the node remembers it (and restores it on rollback). Previously such a removal was skipped without a report.
- Hotcode's own HTTP endpoint processes are never deploy targets. With
carriers: [Bandit.DelegatingHandler](needed to migrate WebSocket state held by Bandit), the process serving the deploy request was matched. It was blocked waiting for the loader, so the loader's:sys.suspendtimed out and the deploy aborted. Found by thelive_edgeexample.
Security
Three independent adversarial reviews, two by Opus. Findings fixed before this release include: a second signer who could be tricked into signing a statement for different code than the one inspected; anonymous clients able to make a node buffer large bodies or evict operators' challenges; a rolled-back patch returning from the store at the next boot; a rollback that made the next boot forget older patches; an unbounded replay counter that one dishonest signer could use to block all later deploys; and several paths in the in-place application restart that left an application stopped or a socket closed. Each has a regression test that fails without the fix. See SECURITY.md.
Fixed after the fourth review (archives, beam parsing, boot replay, build tools):
- Envelopes and bundles are read by
Hotcode.Archive, a small ustar reader, instead of:erl_tar: regular files only (no pax or GNU extension headers, links or directories), names of at most 255 bytes fromA-Z a-z 0-9 . _ - + @ /with no absolute or..path, at most 4096 entries, no name twice, checked header checksums, contents returned without copies. A 30 KB unsigned envelope with pax long-name records cost about 1.6 GB before; it is now refused in about 15 ms.Hotcode.Archive.pack/1writes the format (archives written by earlier versions still read). the envelope reader refuses an envelope abovemax_envelope_bytes(default 64 MB) for every caller, includingmix hotcode.signanddescribe(limits). Hotcode.Hash.code/1decodes a beam'sAttrchunk with:safeand never inflates a compressed term; a chunk that names atoms this VM lacks is hashed without decoding, with the same digest a VM that has the atoms computes. An unsigned 12 KB envelope created 200 000 atoms indescribe, and one trusted key could do the same through a:plan; a 2 KB one inflated 2 GB.Hotcode.Bundle.unpack/1compares the manifest with the archive's beams before parsing any of them, and refuses a gzip-compressed beam ({:bad_beam, name}). A shadow's literal table inflates within 16 MB.- Boot replay: a
store_fetchenvelope is verified before itsseqorders anything; one that fails verification, does not apply or claims theseqof another envelope is skipped and reported on its own, an exact copy is skipped, and a fetched envelope never makes the node rename the files ofstore_dir(one unsigned file claimingseq: 1, or the same envelope twice, discarded the whole local store).fetch_dir/1and the store read only regular files (no symlinks followed, no FIFOs or devices) up tomax_envelope_bytes. Hotcode.Patchfilters the names a manifest lists by the module policy before making atoms of them (removed modules travel as names), and a manifest'sallowed_prefixescan only narrow the builder's ownconfig :hotcode, allowed_prefixes:, never widen it.mix hotcode.installtakes prefixes only from top-leveldefmodules underlib/, drops a namespace owned by another application (Plug,Phoenix), and names every extra prefix in a notice.mix hotcode.push:--targets-cmdruns withoutHOTCODE_KEY,HOTCODE_COOKIE,RELEASE_COOKIEand the variables named by--key env:/--cookie env:; a--targetvalue with whitespace or a control character is refused (a newline added targets andhealth=URLs);--rollback-fileis checked (type, version, audience, expiry past--soak) before anything is deployed.mix hotcode.gen_keyrefuses to overwrite an existingNAME.pubwithout--force.- The pre-push hook works in a
mktemp -ddirectory; the skill's audit script reads only regular files (no symlinks) and at most 2 MB of each;docker/Dockerfiletakes aBASEbuild argument to pin the base image by digest.
Fixed after the fourth review (loader, trust, rolls, spread, HTTP):
- The replay counter is never lowered. The retry a signed resume arms (
allow_retry/2) set the counter back to that statement'sseq, so an envelope a signed rollback had undone in the meantime could be applied again; the counter now keeps its highest value, in memory and on disk. signatures.jsonholds at most 64 entries (more is{:bad_envelope, :too_many_signatures}, refused before any signature is checked), and only the first entry naming each trusted key is verified. One million copies of a trusted fingerprint in a 418 KB envelope held the loader for 40 s.- Every refusal
Hotcode.Trustcan give once one signature is checked counts toward the failure lockout (:manifest_mismatch,{:bad_beam, _}, archive errors,:issued_in_the_future), so repeated badPOST /plancalls with one key lock the node out like bad deploys (Hotcode.Guard). - A plan signed by fewer than
thresholdkeys may create at most 20 000 new atoms, and all such plans together at most 100 000 per boot (config :hotcode, plan_new_atoms:): the atoms are counted from the beams' atom tables without creating any, and a plan over the limit is refused as{:too_many_atoms, count, limit}. One key could fill the atom table through the analyzer of/plan. The count reads every chunk of the beam, takes theAtU8table as:beam_libdoes (a smallAtomchunk placed first no longer hides it, and a beam with two tables of one kind is refused), and counts a name shared by several beams once. - Every well-formed signature entry naming a trusted key is verified (at most 64 entries), so an
entry inserted ahead of the real one in the unsigned
signatures.jsoncannot hide it. - A
public_urlsentry that is not a full URL (no scheme, or not a string) is logged once at error level; the valid entries still work. wait_for_old_code: every node verifies the envelope before it waits, and the wait happens before the roll lock is taken. One request key and an envelope no trusted key signed held the cluster's roll lock for up to 10 minutes.- A
before_deployhook that exits or throws is a veto like one that raises, and the steps of a preflight or plan after verification run guarded like a deploy's. Such a hook crashed the loader during a preflight and lost its rollback history. - The struct scan reads only processes that answer
:sys: aTask, anAgentstarted with a fun or a spawned loop underallowed_prefixesis no longer sent:sys.get_state(it never answered, was counted as a holder, and every struct-changing deploy then failed{:suspend_failed, pid, :timeout}); the plan lists such processes in a:state_not_readwarning.struct_scan: [max_processes:]defaults to 50 000.StructMigrator.holds?/3walks at most 20 000 terms and 24 levels (a larger state counts as a holder). - The check of a
Hotcode.Tableon a copy runs in a task bounded bytable_check: [timeout_ms: 60_000]and refuses tables abovemax_rows: 10_000_000; an upgrade step that never returned held the loader for good. - HTTP: a request signs the authority it was sent to (
host:port), and a node withconfig :hotcode, public_urls: [...]refuses a request signed for another address, so a hostile fleet target can no longer relay an operator's signed/deploy,/rollback,/manifestor/statusto another node that sets it (Hotcode.Trust.sign_request/6, headerx-hotcode-authority; client and server change together). The client follows no redirect (a 3xx is an error;:httpcre-sent the signed headers to the new location), reads at most 8 MB of an answer (64 MB for/manifest, 1 MB for a fleet health check; OTP 27 and later), and warns on plainhttp://off loopback. A locked node answers423only after authentication (anyone else gets401), an anonymous401is logged at:debug(telemetry still gets it), and theHotcode.Serverdocs describe the challenge scheme. - Spread: a node that runs the release decides with the policy of its own verified stack entry
(and serves with its
fanout), and rows that report different policies for the same{version, seq}halt the release ({:policy_conflict, nodes}); a forged row made an honest canary promote without the signed promote. Once a node has verified a resume, only failures and halts said under that resume count (a row claiming epoch 10^16 kept the release halted past every resume). Refused signed promotes and resumes are audited and count toward the lockout, and are refused during it; a node takes its part of a resume only while it sees the release halted, and keeps the seq of the last resume across a restart of the spread process;POST /resumeand/promoteanswer:spread_not_runninginstead of a 500 while that process restarts. Inmode: :spread,Loader.auto_rollback/2undoes only an entry that carries a rollout policy (:no_rollout_policy).
Known limits
See Limits. In particular, leave
allow_app_restart empty until in-place restarts have been tried against your real application
tree.