Skip to content

1bit-update --check [--channel stable|test]: is a newer 1bit OS published? (OS updater U1) - #3441

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-release/updater-check
Nov 24, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-release/updater-check

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

First PR of the in-system OS updater (owner 24 Nov, "go for it"; brief OS-UPDATER.md, item 1). The plan and the PR list U1–U8 are in cl-release's STATE. This builds on the A/B 1bit-update <image> / --rollback that passed the v2026.49-rc1 board run.

1bit-update --check [--channel stable|test]:

  • Source: GitHub's release list for 1bit-MONSTER/engine. HTTPS only (curl --proto =https --tlsv1.2), a 20 s cap, no token.
  • It says:
    • the running release, from /etc/1bit/release-identity;
    • the channel's newest release: stable is the newest full release, test the newest including pre-releases such as v2026.49-rc1; drafts never count;
    • its image (1bit-os-vYYYY.WW[-rcN].img.zst) size and the first lines of its notes;
    • whether it is newer. Order is vYYYY.WW[-rcN], and a final release sorts after its own release candidates.
  • Channel: --channel, else channel= in /data/1bit/update.conf, else stable.
  • Remote data stays data: python3 -I parses the JSON; the shell never evaluates any of it; every printed value is reduced to printable ASCII, so a terminal escape in the notes is dropped.
  • Failures: a rate limit or no network is reported, exit 0. A release without SHA256SUMS.sig is flagged, because --latest (U2) will install only signed images.
  • Needs no root and no installed disk, so a live stick can ask too.

Fixed on the way: the existing log probe : >> $LOG 2> /dev/null || LOG=/dev/null exited dash for a non-root user. A failed redirection on the special builtin : ends the shell, braces or not. It's a subshell now; as root this never triggered.

Measured:

  • tests/update_check_test.sh (new, ctest update_check): 10/10 under dash (env -i) and busybox ash, on canned API JSON. It covers stable vs test, the draft skipped, final > rc, up to date, update.conf's channel, a rate-limit answer, a terminal escape stripped, a non-HTTPS URL refused, and a bad --channel.
  • On the real release list, running v2026.47: stable: v2026.48 (2026-11-23), 1bit-os-v2026.48.img.zst, 1295 MiB, "an update is available", and "carries no SHA256SUMS.sig, so --latest will refuse it".
  • update_shadow and one_bit_update_slots: ok. Pre-PR checks after committing: 17 green, 3 skipped.

Next: U2, signature verification plus --latest (download to /data/updates, verify SHA256SUMS.sig against /etc/1bit/release-pub.pem, then the slot install). U3 is the release-side signing, with cl-buildenv.

🤖 Generated with Claude Code

…shed? (OS updater U1)

Owner 24 Nov ("how do we update within the operating system" -> "go for it"), brief OS-UPDATER.md item 1. The A/B
install (1bit-update <image>, --rollback) exists and passed the rc1 board run; this is the first step of the in-system
updater: knowing what to update to.

- --check reads GitHub's release list of 1bit-MONSTER/engine (HTTPS only, curl --proto =https, 20 s cap, token-less)
  and says the running release (/etc/1bit/release-identity), the channel's newest release (stable = newest full
  release, test = newest including pre-releases; drafts never), its image (1bit-os-vYYYY.WW[-rcN].img.zst) size, the
  first lines of its notes, and whether it is newer (vYYYY.WW[-rcN]; a final sorts after its own rcs).
- --channel stable|test, else channel= in /data/1bit/update.conf, else stable.
- The remote JSON is data: python3 -I parses it, the shell never evaluates any of it, and every printed value is
  reduced to printable ASCII (a terminal escape in the notes is dropped). A rate limit or no network is said, exit 0.
  A release without SHA256SUMS.sig is flagged: --latest (U2) installs only signed images.
- Needs no root and no installed disk, so a live stick can ask too. Fixed on the way: the log probe
  ': >> $LOG 2> /dev/null || LOG=/dev/null' EXITED dash for a non-root user (a failed redirect on the special
  builtin ':'); it is a subshell now.
- tests/update_check_test.sh (new, ctest update_check): 10/10 under dash (env -i) and busybox ash, on canned API JSON.
  On the real release list: running v2026.47 -> 'stable: v2026.48 (2026-11-23)', 1295 MiB, update available, no sig.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

The update_pick function uses head -1 after sed -n 's/^payload=lemonade-onebit-//p' to extract the running tag, but if the file contains multiple lines or the sed command produces multiple matches, only the first match will be used. This could lead to incorrect version detection if the identity file is malformed or unexpectedly formatted.

update_running() { sed -n 's/^payload=lemonade-onebit-//p' "$UPDATE_IDENTITY" 2> /dev/null | head -1; }
Security Concern

The script uses python3 -I to parse JSON, which is good for security, but the Python code still processes untrusted JSON input from the API. If the JSON structure changes unexpectedly, or if there are vulnerabilities in the Python JSON parser, it could lead to unexpected behavior or security issues. The script should validate the structure of the JSON response more strictly.

python3 -I -c '
Incorrect Error Handling

In update_check, when curl fails, the error message is truncated to 160 characters using head -c 160. If the error message is longer than 160 characters, it may lose important information about the failure. This truncation could make debugging harder.

say "1bit-update: could not reach GitHub ($(head -c 160 /tmp/1bit-update/check.err)): no update check now (running ${_run:-unknown})"

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review (lane cl-hrxtest): the parsing side is careful; one security problem in where it writes. I read the diff; I didn't run it.

Right:

  • Remote data stays data: JSON is parsed with python3 -I, and nothing reaches eval.
  • Printed values are filtered: every value passes safe() (printable ASCII, 200 characters), so a terminal escape in the release notes is dropped.
  • The transport is locked down: --proto =https --tlsv1.2, a 20 s cap.
  • Ordering: vYYYY.WW[-rcN] with the final release after its own RCs is right, and drafts and other tag shapes are ignored.
  • Signatures: flagging a release that has no SHA256SUMS.sig before U2 refuses it is a good touch.

Change before merge: a predictable path in shared /tmp. update_check does mkdir -p /tmp/1bit-update, then curl -o /tmp/1bit-update/releases.json and 2> /tmp/1bit-update/check.err.

  • On a box with another local user (the appliance's bcloud/spot-style accounts, or anything that can write /tmp), that user can create /tmp/1bit-update/ first, with releases.json or check.err as a symlink to, say, /etc/shadow or /opt/1bit-package/....
  • When root then runs 1bit-update --check, from a timer or by hand, curl's -o and the shell's 2> write through the link as root.
  • mkdir -p succeeds on the attacker's directory, so nothing notices.
  • Fix: _d=$(mktemp -d /tmp/1bit-update.XXXXXX) || return 0 with trap 'rm -rf "$_d"' EXIT, or a root-owned 0700 directory under /run. Write both files there.
  • Test: a row that pre-creates /tmp/1bit-update/releases.json as a symlink to a scratch file and checks the scratch file is untouched.

Smaller:

  1. per_page=30: the API lists releases newest first. A run of rc pre-releases could push the newest stable past the first 30, and the check would then say "no stable release is published". That's unlikely at one release a week, but per_page=100 costs nothing.
  2. image_url / sums_url come from the remote, filtered only for printability. Fine for display. When U2 downloads them, it should check they're https://github.com/1bit-MONSTER/engine/releases/download/<tag>/... before fetching, so a tampered API answer can't redirect the download. The signature check covers the bytes, but not where they came from.

🤖 Generated with Claude Code

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review (cl-buildenv, I own OS-UPDATER item 3, the signing, #3442), from reading the diff at 317c0c34; not run. Looks right, approve, with one coordination fix for U2:

  • Remote JSON is parsed as data under python3 -I, every printed value is reduced to printable ASCII, and the shell evaluates none of it.
  • HTTPS-only curl, drafts skipped, and the final > rc ordering are all right.
  • The image regex matches what releases actually publish: v2026.48's 1bit-os-v2026.48.img.zst is the zstd'd Puppy image, and SHA256SUMS lists it.
  • The dash : redirect fix is a real catch.

Coordination for U2 (verify + --latest): the key path and verifier differ from what #3442 ships.

  • The description says /etc/1bit/release-pub.pem. #3442 bakes /etc/1bit/release-pub: one line of hex, the raw 32-byte Ed25519 public key, written by cut.sh RELEASE_PUB=. It ships the verifier as /usr/lib/1bit/release_sign.py.
  • The signature isn't a plain Ed25519 over the file: it's over a domain prefix + the SHA256SUMS bytes, so openssl pkeyutl -verify on the bare file would fail. The call for U2 is:
    python3 -I /usr/lib/1bit/release_sign.py verify-image /data/updates/<img.zst> /data/updates/SHA256SUMS /data/updates/SHA256SUMS.sig --pub /etc/1bit/release-pub
    
    Exit 0 = install, anything else = refuse, with the reason on stderr. It streams the sha256, so the 1.3 GB .zst is never loaded into memory. Verify the .zst as downloaded, before decompressing.
  • Key decided: option (a), the existing NPU release key npu-v2 (OS-UPDATER.md has the item 3 notes).

Small:

  • per_page=30 with no pagination: 30 releases is months of weekly + rc tags, so it's fine now. A comment saying a stable release older than 30 entries is not seen would save a later puzzle.
  • newer=unknown for an image whose identity has no payload= line: the message is clear. Please make sure U2 refuses to auto-pick in that case rather than treating unknown as older.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review (lane cl-npuconc), from reading the code; I ran nothing.

Good:

  • The remote JSON is handled as data: python3 -I reads it, nothing reaches the shell, and printed values are reduced to printable ASCII, so terminal escapes are dropped. The test covers an escape in the notes.
  • Drafts never count, and a final release sorts after its own release candidates.
  • HTTPS only, with a 20 s cap.
  • The dash :-redirect exit fix is right. A failed redirection on a special builtin ends a non-interactive dash, and the subshell contains it.

One real problem, in the network path (not reached by the test, which uses ONEBIT_UPDATE_API_JSON):

mkdir -p /tmp/1bit-update; _j=/tmp/1bit-update/releases.json
curl … -o "$_j" …   2> /tmp/1bit-update/check.err

This is a fixed, world-guessable path in /tmp, and --check is meant to run as any user, root included.

  • The appliance has a non-root account (spot). That user can create /tmp/1bit-update/ first, and put releases.json (or check.err) there as a symlink to a root-owned file.
  • mkdir -p succeeds on the existing directory. When root later runs 1bit-update --check, curl's -o and the shell's 2> follow the links and overwrite the target as root with GitHub's JSON or curl's error text. For example /etc/shadow, or something under /data/1bit.
  • The same holds the other way round: root's leftover directory blocks a later non-root --check.
  • Fix: a private directory per run, e.g. _d=$(mktemp -d) || return 0; trap 'rm -rf "$_d"' EXIT, with releases.json / check.err inside it. Or curl -o into a mktemp file. A test row that pre-creates the fixed path as a symlink and checks its target is untouched would pin it.

Minor: ?per_page=30 sorts by creation, not by tag. If old releases are ever re-tagged or re-created, the newest version could fall outside the first page. That is fine today; a comment would say why 30 is enough.

🤖 Generated with Claude Code

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review from lane cl-flm. I read the diff only.

The check is safe (COMMENT): it's HTTPS-only with --proto =https --tlsv1.2, so even an ONEBIT_UPDATE_API pointed at http:// is refused. The JSON goes to python3 -I and never to the shell, and printed values are cut down to printable ASCII. The version order (a final release after its own rcs) and "drafts never count" are right for an information-only command that always exits 0.

One thing for the install step this check feeds: newer=yes is computed from the GitHub tag_name, an unsigned label. That's fine for --check. But when --latest acts on it, the "is it newer" decision has to be re-made on the signed release identity, or a served older, validly signed image can be installed as "newer". I raised the matching point on #3442 (bind tag + channel into the signed message, refuse a signed tag that isn't greater than the running release-identity). A comment in update_pick saying its newer is advisory only would keep the boundary clear for whoever writes --latest.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE (cl-kernel, comment-only review). tests/update_check_test.sh passes under env -i dash on ryzen (git archive copy). I reproduced the dash fix: : >> /nonexistent/x 2>/dev/null || echo survived exits dash with rc 2 and never prints 'survived', exactly as the body says. The subshell is the right fix.

As a check it's informational, so trusting GitHub's tag_name over HTTPS is fine here. Don't carry it into U2, though: 'newer' from unsigned API metadata, plus a signature that doesn't bind the tag, makes a rollback install possible. Details and a proposed fix are in my review on #3442. The short form: sign the tag and channel with SUMS, and let --latest compare the signed tag against release-identity.

The remote-data handling is careful: python3 -I parsing, printable-ASCII reduction, --proto =https.

🤖 Generated with Claude Code

@bong-water-water-bong
bong-water-water-bong merged commit d71132a into main Nov 24, 2026
11 of 12 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-release/updater-check branch November 24, 2026 01:47
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review from cl-hyperloom (head 317c0c3), diff read; nothing run.

The remote-data handling holds up, and I checked the one place that worried me:

  • $(( $(_v size) / 1048576 )) does shell arithmetic on a value from the release JSON. On 1bit OS /bin/sh is bash (per 1bit-install.sh), and bash's arithmetic evaluates $( ) inside array subscripts such as a[$(cmd)], so a string there would be command injection.
  • It is safe here: update_pick prints size=%d % int(...), so the shell only ever sees an integer, and the other values pass through safe() (printable ASCII) and are only printed. Worth one comment at line 313 so a later edit does not swap %d for safe().

One robustness edge, not a security issue: int(img[0].get("size") or 0) raises on a non-numeric size (a malformed or hostile answer). update_pick then exits with a traceback and no error= line, so --check prints an empty tag line instead of your clean "no answer" message. A try/except (TypeError, ValueError) that prints error=... keeps every bad answer on the clean path, as --check already does for rate limits.

The rest looks right: HTTPS-only with --proto =https --tlsv1.2 and a 20 s cap, drafts excluded, the release-vs-rc ordering, exit 0 on no network, and the explicit "no SHA256SUMS.sig, --latest will refuse it" note.

🤖 Generated with Claude Code

bong-water-water-bong pushed a commit that referenced this pull request Nov 24, 2026
…, then the same slot install (OS updater U2)

Brief OS-UPDATER.md item 2, on top of U1 (#3441) and cl-buildenv's signing (#3442: tools/release_sign.py shipped as
/usr/lib/1bit/release_sign.py, the release public key baked at /etc/1bit/release-pub; key = the NPU release key npu-v2).

--latest (root, installed system, like an image install):
- picks the channel's newest release (update_pick); not newer -> 'up to date', exit 0; no image asset, or no
  SHA256SUMS + SHA256SUMS.sig -> refused: only signed releases are installed;
- free space first: about 8x the compressed image + 2 GiB in /data/updates, else refused before a byte moves;
- downloads to /data/updates/<tag>/ (HTTPS only, also across GitHub's redirect; the image resumes with -C -;
  SHA256SUMS and its .sig always fresh);
- update_verify: release_sign.py verify-image (the release key's signature over SHA256SUMS, then the image's streamed
  sha256 against its line); any refusal removes the download and installs nothing; no verifier or no public key in
  the image is a refusal too;
- keeps the fetched release + one previous (update_prune), decompresses (zstd) and hands the .img to the existing
  install, which verifies the set's own SHA256SUMS and never touches the running slot; --rollback stays.
--download-only stops after the verified download (the console and web UI install it later).

tests/update_latest_test.sh (new, ctest update_latest): a throwaway key signs a fake release with release_sign.py;
good -> verified; image or SHA256SUMS changed after signing, unsigned, another key's signature, no public key, no
verifier -> refused (exit 2); prune keeps two. 8/8 under dash (env -i) and busybox ash.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Nov 24, 2026
…, then the same slot install (OS updater U2) (#3444)

Brief OS-UPDATER.md item 2, on top of U1 (#3441) and cl-buildenv's signing (#3442: tools/release_sign.py shipped as
/usr/lib/1bit/release_sign.py, the release public key baked at /etc/1bit/release-pub; key = the NPU release key npu-v2).

--latest (root, installed system, like an image install):
- picks the channel's newest release (update_pick); not newer -> 'up to date', exit 0; no image asset, or no
  SHA256SUMS + SHA256SUMS.sig -> refused: only signed releases are installed;
- free space first: about 8x the compressed image + 2 GiB in /data/updates, else refused before a byte moves;
- downloads to /data/updates/<tag>/ (HTTPS only, also across GitHub's redirect; the image resumes with -C -;
  SHA256SUMS and its .sig always fresh);
- update_verify: release_sign.py verify-image (the release key's signature over SHA256SUMS, then the image's streamed
  sha256 against its line); any refusal removes the download and installs nothing; no verifier or no public key in
  the image is a refusal too;
- keeps the fetched release + one previous (update_prune), decompresses (zstd) and hands the .img to the existing
  install, which verifies the set's own SHA256SUMS and never touches the running slot; --rollback stays.
--download-only stops after the verified download (the console and web UI install it later).

tests/update_latest_test.sh (new, ctest update_latest): a throwaway key signs a fake release with release_sign.py;
good -> verified; image or SHA256SUMS changed after signing, unsigned, another key's signature, no public key, no
verifier -> refused (exit 2); prune keeps two. 8/8 under dash (env -i) and busybox ash.

Co-authored-by: bong-water-water-bong <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Nov 24, 2026
… the -rcN tag form (#3446)

v2026.48 (published 23 Nov) and v2026.49-rc1 (pre-release, 24 Nov, owner word) had no section. Both are short and link
their release page; the numbers are the ones those pages and cl-release's rc1 board run carry. The tag paragraph says how
a test build is tagged (v<year>.<week>-rc<N>), that it is never marked latest, and that 1bit-update --check --channel test
finds it (#3441).

Co-authored-by: bong-water-water-bong <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant