feat(sirius-press): a WordPress where the account is a key, not a mailbox
WordPress makes two assumptions this project cannot accept: that identity
comes from an email address, and that a site lives at one server. Both are
things somebody else can take away — a mailbox is rented from a provider who
can close it or be compelled to open it, and a server is one seizure from
being gone.
Sirius Press replaces the first and hedges the second.
Signing in means signing a challenge with the key that controls a CashAddress.
The address is recovered from the signature, so nothing is typed but the
signature itself, and the result is an ordinary WordPress session cookie —
roles, capabilities, nonces and the REST API never learn the login was
different. Three ways to produce one: a wallet the browser already exposes, a
phrase used once in the page and wiped, or a signature pasted in from any
BIP-137 wallet, which needs no JavaScript and lets the key stay on a machine
that never touches the web.
There is no password reset, and the recovery page says so plainly rather than
offering a form that cannot work. A reset mechanism is by construction a way
to take an account from its owner, and it is always easier to attack than the
cryptography it bypasses.
Publishing a post also exports it as static HTML to the name's storage on Sia,
signed by the key that owns the name, so the site keeps answering when the
server does not.
Email as a feature is untouched. wp_mail() still works, SMTP still sends, and
contact forms still deliver to addresses real people typed. Only mail to the
site's own unroutable placeholder addresses is diverted to an in-app inbox.
The objection was to email as identity, not to email.
Core is pinned and patched rather than vendored. WordPress 7.1.1 is 149 MB and
5,008 files; the fork's entire core diff is 75 lines in wp-admin/install.php.
Carrying the former to express the latter would bury the patch where nobody
reviews it and make every clone of the monorepo pay for it. Upstream releases
still merge through tools/update-wordpress.sh, which reapplies the series and
says exactly which hunk needs a human.
The cryptography is implemented twice — PHP on the server, JavaScript in the
page — because the server must verify and the browser must sign. Both are
pinned against libauth, the library the Sirius portal wallet and the BNS
gateway already use, so a disagreement of one byte fails the test suite rather
than presenting as a rejected login at three in the morning.
132 checks, no framework, about a second.
2026-09-21 01:39:38 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* URL-to-path mapping and link rewriting.
|
|
|
|
|
*
|
|
|
|
|
* A wrong answer here is silent. Two pages that map to one path means one
|
|
|
|
|
* quietly overwrites the other, and nobody finds out until a reader opens an
|
|
|
|
|
* article and gets a different one. A link rewritten wrongly means the static
|
|
|
|
|
* copy points back at the origin server it exists to make optional.
|
|
|
|
|
*
|
|
|
|
|
* So the cases below are mostly the awkward ones: a URL that looks like a file
|
|
|
|
|
* but is a page, a path the gateway would refuse, a document deep in a tree
|
|
|
|
|
* linking back up to an asset at the root.
|
|
|
|
|
*
|
|
|
|
|
* @package SiriusPress
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
require_once __DIR__ . '/bootstrap.php';
|
|
|
|
|
|
|
|
|
|
T::group( 'gateway path rules' );
|
|
|
|
|
|
|
|
|
|
T::is( SP_Gateway::clean_path( '/blog/hello/index.html' ), 'blog/hello/index.html', 'a leading slash is dropped' );
|
|
|
|
|
T::is( SP_Gateway::clean_path( 'blog//hello///index.html' ), 'blog/hello/index.html', 'repeated slashes collapse' );
|
|
|
|
|
T::is( SP_Gateway::clean_path( 'a/../../etc/passwd' ), '', 'traversal is refused' );
|
|
|
|
|
T::is( SP_Gateway::clean_path( 'blog/' ), '', 'a trailing slash is refused — the gateway stores objects, not directories' );
|
|
|
|
|
T::is( SP_Gateway::clean_path( '' ), '', 'an empty path is refused' );
|
|
|
|
|
T::is( SP_Gateway::clean_path( 'café/index.html' ), '', 'characters the gateway rejects are refused here' );
|
|
|
|
|
T::is( SP_Gateway::clean_path( str_repeat( 'a', 201 ) ), '', 'an over-long path is refused' );
|
|
|
|
|
T::is( SP_Gateway::clean_path( 'wp-content/themes/x/style.css' ), 'wp-content/themes/x/style.css', 'an asset path survives' );
|
|
|
|
|
|
|
|
|
|
T::is( SP_Gateway::mime_for( 'index.html' ), 'text/html; charset=utf-8', 'html content type' );
|
|
|
|
|
T::is( SP_Gateway::mime_for( 'app.CSS' ), 'text/css; charset=utf-8', 'extensions are matched case-insensitively' );
|
|
|
|
|
T::is( SP_Gateway::mime_for( 'thing.unknown' ), 'application/octet-stream', 'an unknown extension falls back' );
|
|
|
|
|
|
|
|
|
|
T::group( 'URL to bucket path' );
|
|
|
|
|
|
|
|
|
|
$cases = array(
|
|
|
|
|
'/' => 'index.html',
|
|
|
|
|
'' => 'index.html',
|
|
|
|
|
'/hello-world/' => 'hello-world/index.html',
|
|
|
|
|
'/hello-world' => 'hello-world/index.html',
|
|
|
|
|
'/blog/2026/09/a-post/' => 'blog/2026/09/a-post/index.html',
|
|
|
|
|
'/robots.txt' => 'robots.txt',
|
|
|
|
|
'/wp-content/themes/x/style.css' => 'wp-content/themes/x/style.css',
|
|
|
|
|
'/sitemap.xml' => 'sitemap.xml',
|
|
|
|
|
// Ends in a slash, so it is a page whose name happens to contain a dot —
|
|
|
|
|
// not a file called "about.us".
|
|
|
|
|
'/about.us/' => 'about.us/index.html',
|
|
|
|
|
);
|
|
|
|
|
foreach ( $cases as $url => $expected ) {
|
|
|
|
|
T::is( SPE_Mapper::path_for_url_path( $url ), $expected, "'{$url}' maps to '{$expected}'" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
T::ok( SPE_Mapper::is_asset( 'wp-content/x.css' ), 'a stylesheet is an asset' );
|
|
|
|
|
T::ok( SPE_Mapper::is_asset( 'a/b/photo.JPG' ), 'an uppercase extension still reads as an asset' );
|
|
|
|
|
T::ok( ! SPE_Mapper::is_asset( 'blog/post/index.html' ), 'a page is not an asset' );
|
|
|
|
|
|
|
|
|
|
// Distinct pages must never land on one path.
|
|
|
|
|
$paths = array();
|
|
|
|
|
foreach ( array( '/a/', '/b/', '/a/b/', '/a/b/c/', '/a.html', '/ab/' ) as $url ) {
|
|
|
|
|
$paths[] = SPE_Mapper::path_for_url_path( $url );
|
|
|
|
|
}
|
|
|
|
|
T::is( count( array_unique( $paths ) ), count( $paths ), 'six distinct URLs give six distinct paths' );
|
|
|
|
|
|
|
|
|
|
// `/a/` and `/a/index.html` are the same page in WordPress and are SUPPOSED to
|
|
|
|
|
// share a path — this records that as intended, not as the collision above.
|
|
|
|
|
T::is(
|
|
|
|
|
SPE_Mapper::path_for_url_path( '/a/' ),
|
|
|
|
|
SPE_Mapper::path_for_url_path( '/a/index.html' ),
|
|
|
|
|
'a directory URL and its explicit index are one page'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
T::group( 'document-relative links' );
|
|
|
|
|
|
|
|
|
|
$relative = array(
|
|
|
|
|
// from to expected
|
|
|
|
|
array( 'index.html', 'about/index.html', 'about/index.html' ),
|
|
|
|
|
array( 'about/index.html', 'index.html', '../index.html' ),
|
|
|
|
|
array( 'blog/post/index.html', 'wp-content/app.css', '../../wp-content/app.css' ),
|
|
|
|
|
array( 'blog/post/index.html', 'blog/other/index.html', '../other/index.html' ),
|
|
|
|
|
array( 'a/b/c/index.html', 'a/b/c/style.css', 'style.css' ),
|
|
|
|
|
array( 'index.html', 'index.html', 'index.html' ),
|
|
|
|
|
);
|
|
|
|
|
foreach ( $relative as $case ) {
|
|
|
|
|
list( $from, $to, $expected ) = $case;
|
|
|
|
|
T::is( SPE_Renderer::relative( $from, $to ), $expected, "{$from} -> {$to}" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
T::group( 'rewriting a page' );
|
|
|
|
|
|
|
|
|
|
$html = '<!doctype html><html><head>'
|
|
|
|
|
. '<link rel="stylesheet" href="https://example.test/wp-content/themes/x/style.css?ver=1.2">'
|
|
|
|
|
. '<link rel="canonical" href="https://example.test/blog/hello/">'
|
|
|
|
|
. '</head><body>'
|
|
|
|
|
. '<a href="https://example.test/">Home</a>'
|
|
|
|
|
. '<a href="https://example.test/about/">About</a>'
|
|
|
|
|
. '<a href="https://elsewhere.example/offsite">Offsite</a>'
|
|
|
|
|
. '<img src="//example.test/wp-content/uploads/pic.png" alt="">'
|
|
|
|
|
. '<a href="https://example.test/blog/hello/#notes">Notes</a>'
|
|
|
|
|
. '</body></html>';
|
|
|
|
|
|
|
|
|
|
$result = SPE_Renderer::rewrite( $html, 'blog/hello/index.html' );
|
|
|
|
|
$out = $result['html'];
|
|
|
|
|
|
|
|
|
|
T::ok( false === strpos( $out, 'https://example.test' ), 'no absolute self-links remain' );
|
|
|
|
|
T::ok( false !== strpos( $out, 'href="../../index.html"' ), 'the home link became document-relative' );
|
|
|
|
|
T::ok( false !== strpos( $out, 'href="../../about/index.html"' ), 'an internal page link became relative' );
|
|
|
|
|
T::ok( false !== strpos( $out, 'href="https://elsewhere.example/offsite"' ), 'an external link is left alone' );
|
|
|
|
|
T::ok(
|
|
|
|
|
false !== strpos( $out, 'href="../../wp-content/themes/x/style.css"' ),
|
|
|
|
|
'the ?ver= query is dropped from an asset, which the bucket stores once'
|
|
|
|
|
);
|
|
|
|
|
T::ok( false !== strpos( $out, 'src="../../wp-content/uploads/pic.png"' ), 'a protocol-relative URL is rewritten too' );
|
|
|
|
|
T::ok( false !== strpos( $out, 'href="index.html#notes"' ), 'a fragment survives rewriting' );
|
|
|
|
|
|
|
|
|
|
T::ok( isset( $result['assets']['wp-content/themes/x/style.css'] ), 'the stylesheet was collected for export' );
|
|
|
|
|
T::ok( isset( $result['assets']['wp-content/uploads/pic.png'] ), 'the image was collected for export' );
|
|
|
|
|
T::is(
|
|
|
|
|
$result['assets']['wp-content/themes/x/style.css'],
|
|
|
|
|
'https://example.test/wp-content/themes/x/style.css',
|
|
|
|
|
'a collected asset carries the URL to fetch it from'
|
|
|
|
|
);
|
|
|
|
|
T::ok( ! isset( $result['assets']['about/index.html'] ), 'a page is not collected as an asset' );
|
|
|
|
|
|
fix(sirius-press): recovering a key is not the same as verifying a signature
Running the fork against a live WordPress found a real hole in registration,
and it is the kind that only shows up when you actually try it.
ECDSA public-key recovery always succeeds. Given any well-formed signature
and any digest it returns a key — just not the signer's, unless the digest is
the one that was signed. The auth flow leaned on that as if a wrong message
would fail. It does not; it quietly yields a stranger's address.
At sign-in this was harmless, because the wrong address matches no account
and the attempt fails. Registration and wallet-linking were another matter:
both took the recovered address and bound it to an account, so a signature
over slightly different text — a challenge copied without its blank line, a
wallet that rewrote the text, a login signature replayed at the registration
form — created an account keyed to an address nobody could sign for. The
person would see "success" and discover the truth the next time they tried to
get in. Wallet-linking was worse still: it would move an existing account onto
a dead address and lock its owner out of their own site.
Both paths now require the address the signer claims and compare it to the
recovered one, which is what verification actually means. Sign-in accepts the
claim when the page sends it and uses it to turn "no account uses that wallet"
into the more useful "that signature is not over the text we asked for".
Also from running it:
URL rewriting mangled every link on a site whose URL carries a port. The
protocol-relative pass matched inside absolute URLs and gave each one a second
scheme, and matching the host without its port left the port stranded as
`//host:8760:8760/`. Local and staging installs would have exported a site of
broken links.
Plain permalinks silently collapse an entire site onto one exported file,
because every post's URL is `/?p=N` and its path is `/`. The queue looks
healthy the whole time. The Publishing screen now says so.
Translations loaded on `plugins_loaded`, which WordPress 6.7 warns about on
every request — the kind of noise that trains people to stop reading logs.
And one deletion: an `is_email()` filter written on the assumption that
WordPress rejects `.invalid` addresses. It does not — `is_email()` validates
syntax, not whether a domain could exist — so the filter never fired. A filter
that appears to relax a rule but does not is worse than no filter, because
someone later reasons from it. The documentation made the same claim and has
been corrected.
Verification added rather than asserted: tests/live.mjs drives a real instance
over HTTP (40 checks), and tests/mock-gateway.mjs answers uploads with the
signature check transcribed from the gateway's own source, so the publishing
path can be exercised without a registered name.
2026-09-21 02:35:32 +02:00
|
|
|
T::group( 'rewriting when the site URL carries a port' );
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* A local instance, a staging box behind a port, anything not on 80 or 443.
|
|
|
|
|
* This case is worth its own group because two separate bugs lived here: a
|
|
|
|
|
* naive protocol-relative pass that matched inside every absolute URL and
|
|
|
|
|
* gave each one a second scheme, and a host-only match that left the port
|
|
|
|
|
* stranded as `//host:8760:8760/`. Both produced links that looked almost
|
|
|
|
|
* right and went nowhere.
|
|
|
|
|
*/
|
|
|
|
|
// Swap the stub's idea of where the site is for the length of this group.
|
|
|
|
|
$GLOBALS['sirius_test_home'] = 'http://127.0.0.1:8760';
|
|
|
|
|
|
|
|
|
|
$with_port =
|
|
|
|
|
'<a href="http://127.0.0.1:8760/?feed=rss2">feed</a>'
|
|
|
|
|
. '<a href="http://127.0.0.1:8760/">home</a>'
|
|
|
|
|
. '<a href="http://127.0.0.1:8760/about/">about</a>'
|
|
|
|
|
. '<img src="//127.0.0.1:8760/wp-content/x.png">';
|
|
|
|
|
|
|
|
|
|
$ported_out = SPE_Renderer::rewrite( $with_port, 'index.html' )['html'];
|
|
|
|
|
|
|
|
|
|
T::ok( false === strpos( $ported_out, 'http:http' ), 'no doubled scheme' );
|
|
|
|
|
T::ok( false === strpos( $ported_out, ':8760:8760' ), 'no doubled port' );
|
|
|
|
|
T::ok( false === strpos( $ported_out, '127.0.0.1' ), 'no absolute self-links remain' );
|
|
|
|
|
T::ok( false !== strpos( $ported_out, 'href="index.html?feed=rss2"' ), 'a query survives on the home page' );
|
|
|
|
|
T::ok( false !== strpos( $ported_out, 'href="about/index.html"' ), 'an internal link is relative' );
|
|
|
|
|
T::ok( false !== strpos( $ported_out, 'src="wp-content/x.png"' ), 'a protocol-relative asset keeps its port stripped cleanly' );
|
|
|
|
|
|
|
|
|
|
unset( $GLOBALS['sirius_test_home'] );
|
|
|
|
|
|
|
|
|
|
T::group( 'the export marker' );
|
|
|
|
|
|
feat(sirius-press): a WordPress where the account is a key, not a mailbox
WordPress makes two assumptions this project cannot accept: that identity
comes from an email address, and that a site lives at one server. Both are
things somebody else can take away — a mailbox is rented from a provider who
can close it or be compelled to open it, and a server is one seizure from
being gone.
Sirius Press replaces the first and hedges the second.
Signing in means signing a challenge with the key that controls a CashAddress.
The address is recovered from the signature, so nothing is typed but the
signature itself, and the result is an ordinary WordPress session cookie —
roles, capabilities, nonces and the REST API never learn the login was
different. Three ways to produce one: a wallet the browser already exposes, a
phrase used once in the page and wiped, or a signature pasted in from any
BIP-137 wallet, which needs no JavaScript and lets the key stay on a machine
that never touches the web.
There is no password reset, and the recovery page says so plainly rather than
offering a form that cannot work. A reset mechanism is by construction a way
to take an account from its owner, and it is always easier to attack than the
cryptography it bypasses.
Publishing a post also exports it as static HTML to the name's storage on Sia,
signed by the key that owns the name, so the site keeps answering when the
server does not.
Email as a feature is untouched. wp_mail() still works, SMTP still sends, and
contact forms still deliver to addresses real people typed. Only mail to the
site's own unroutable placeholder addresses is diverted to an in-app inbox.
The objection was to email as identity, not to email.
Core is pinned and patched rather than vendored. WordPress 7.1.1 is 149 MB and
5,008 files; the fork's entire core diff is 75 lines in wp-admin/install.php.
Carrying the former to express the latter would bury the patch where nobody
reviews it and make every clone of the monorepo pay for it. Upstream releases
still merge through tools/update-wordpress.sh, which reapplies the series and
says exactly which hunk needs a human.
The cryptography is implemented twice — PHP on the server, JavaScript in the
page — because the server must verify and the browser must sign. Both are
pinned against libauth, the library the Sirius portal wallet and the BNS
gateway already use, so a disagreement of one byte fails the test suite rather
than presenting as a rejected login at three in the morning.
132 checks, no framework, about a second.
2026-09-21 01:39:38 +02:00
|
|
|
// The exporter's own marker must never survive into a published page: every
|
|
|
|
|
// internal link would carry it, and the published copy would then be asking
|
|
|
|
|
// for the export-rendered variant of every page.
|
|
|
|
|
$flagged = '<a href="https://example.test/about/?sirius_export=abc123">About</a>';
|
|
|
|
|
$rewrote = SPE_Renderer::rewrite( $flagged, 'index.html' )['html'];
|
|
|
|
|
T::ok( false === strpos( $rewrote, 'sirius_export' ), 'the export marker is stripped' );
|
|
|
|
|
|
|
|
|
|
exit( T::summary() );
|