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
/**
* The thing a user signs to prove who they are .
*
* A challenge is a short piece of text this site produced , which the user
* signs with their wallet . The signature comes back , the public key is
* recovered from it , and the address that public key controls * is * the
* identity — nothing had to be typed , remembered or emailed .
*
* ** Stateless issue , stateful consume .** Handing out a challenge writes
* nothing : the nonce carries its own timestamp and an HMAC under the site ' s
* salts , so a forged nonce fails arithmetic rather than a database lookup ,
* and a login page that is rendered and abandoned costs nothing . Only a
* * successful * verification writes — a short - lived marker that burns the
* nonce , so the same signature cannot be replayed .
*
* ** The message is reconstructed , never trusted .** The client sends back the
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
* nonce and what it was for ; this class rebuilds the exact text from those and
* recovers the signer from the rebuilt copy .
*
* ** Recovery is not verification .** This is the subtle part , and getting it
* wrong is how a wallet - auth system quietly breaks . 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
* actually signed . So a signature over the wrong text does not produce an
* error , it produces a stranger ' s address .
*
* At sign - in that is harmless : the wrong address matches no account and the
* attempt fails . Anywhere the outcome * binds * an address to an account —
* registration , attaching a wallet — it is not harmless at all , because the
* account would be bound to an address nobody can sign for , and the person
* would only discover it the next time they tried to sign in .
*
* So those callers pass the address the signer claims , and verification means
* " the recovered address is that one " . A mismatch is then a clear error
* instead of a broken account , and a login signature genuinely cannot be
* replayed to register : it recovers to a different address than the one the
* request claims .
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
*
* @ package SiriusPress
*/
defined ( 'ABSPATH' ) || exit ;
final class SPA_Challenge {
/** How long a challenge stays signable. */
const TTL = 600 ;
const PURPOSE_LOGIN = 'login' ;
const PURPOSE_REGISTER = 'register' ;
const PURPOSE_LINK = 'link' ;
const PURPOSE_CONFIRM = 'confirm' ;
private static function salt () {
return wp_salt ( 'auth' ) . '|sirius-press-challenge|v1' ;
}
/**
* Mint a nonce : `<issued_ms>.<random>.<tag>` .
*
* The tag binds the first two parts to this site ' s salts , so a nonce
* cannot be invented elsewhere and the server does not have to remember
* which ones it gave out .
*/
public static function issue () {
$ts = ( int ) round ( microtime ( true ) * 1000 );
$rand = bin2hex ( random_bytes ( 8 ) );
$body = $ts . '.' . $rand ;
return $body . '.' . substr ( hash_hmac ( 'sha256' , $body , self :: salt () ), 0 , 32 );
}
/**
* Check a nonce ' s shape , tag and age .
*
* @ return int | WP_Error Issue time in milliseconds .
*/
public static function inspect ( $nonce ) {
$parts = explode ( '.' , ( string ) $nonce );
if ( 3 !== count ( $parts ) || ! ctype_digit ( $parts [ 0 ] ) || ! ctype_xdigit ( $parts [ 1 ] ) ) {
return new WP_Error ( 'sirius_bad_nonce' , __ ( 'That sign-in request is malformed. Reload the page and try again.' , 'sirius-press' ) );
}
$expected = substr ( hash_hmac ( 'sha256' , $parts [ 0 ] . '.' . $parts [ 1 ], self :: salt () ), 0 , 32 );
if ( ! hash_equals ( $expected , $parts [ 2 ] ) ) {
return new WP_Error ( 'sirius_bad_nonce' , __ ( 'That sign-in request did not come from this site. Reload the page and try again.' , 'sirius-press' ) );
}
$age = ( round ( microtime ( true ) * 1000 ) - ( int ) $parts [ 0 ] ) / 1000 ;
if ( $age > self :: TTL || $age < - 60 ) {
return new WP_Error ( 'sirius_expired' , __ ( 'That sign-in request has expired. Reload the page and try again.' , 'sirius-press' ) );
}
return ( int ) $parts [ 0 ];
}
/**
* The exact text to be signed .
*
* Written to be readable in a wallet ' s approval dialog , because that is
* the only place a user gets to check what they are agreeing to . Anything
* in here that a wallet renders as a wall of hex is a security control the
* user cannot exercise .
*
* @ param string $nonce
* @ param string $purpose One of the PURPOSE_ * constants .
* @ return string
*/
public static function message ( $nonce , $purpose = self :: PURPOSE_LOGIN ) {
$issued = self :: inspect ( $nonce );
$when = is_wp_error ( $issued ) ? 0 : ( int ) floor ( $issued / 1000 );
$lines = array (
self :: headline ( $purpose ),
'' ,
'Site: ' . home_url ( '/' ),
'Purpose: ' . self :: purpose_label ( $purpose ),
'Nonce: ' . $nonce ,
'Issued: ' . gmdate ( 'Y-m-d\TH:i:s\Z' , $when ),
'' ,
'Signing this proves you control this wallet. It moves no coins.' ,
);
return implode ( " \n " , $lines );
}
private static function headline ( $purpose ) {
$site = wp_specialchars_decode ( get_bloginfo ( 'name' ), ENT_QUOTES );
switch ( $purpose ) {
case self :: PURPOSE_REGISTER :
return sprintf ( 'Create an account on %s' , $site );
case self :: PURPOSE_LINK :
return sprintf ( 'Attach this wallet to your account on %s' , $site );
case self :: PURPOSE_CONFIRM :
return sprintf ( 'Confirm an action on %s' , $site );
default :
return sprintf ( 'Sign in to %s' , $site );
}
}
private static function purpose_label ( $purpose ) {
$known = array (
self :: PURPOSE_LOGIN => 'sign in' ,
self :: PURPOSE_REGISTER => 'create account' ,
self :: PURPOSE_LINK => 'attach wallet' ,
self :: PURPOSE_CONFIRM => 'confirm action' ,
);
return isset ( $known [ $purpose ] ) ? $known [ $purpose ] : 'sign in' ;
}
/** Purposes a request is allowed to name. */
public static function is_known_purpose ( $purpose ) {
return in_array (
$purpose ,
array ( self :: PURPOSE_LOGIN , self :: PURPOSE_REGISTER , self :: PURPOSE_LINK , self :: PURPOSE_CONFIRM ),
true
);
}
/**
* Verify a signature and return the address that made it .
*
* Burns the nonce on success , so a captured signature is worth one use and
* that use has already happened .
*
* @ param string $nonce
* @ param string $signature Base64 , 65 bytes .
* @ param string $purpose
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
* @ param string $claimed The address the caller says signed . Required by
* any caller that will bind the result to an
* account ; see the note on recovery above . When
* given , a recovered address that differs is an
* error rather than a new identity .
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
* @ return string | WP_Error Normalised CashAddress .
*/
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
public static function verify ( $nonce , $signature , $purpose = self :: PURPOSE_LOGIN , $claimed = '' ) {
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
if ( ! self :: is_known_purpose ( $purpose ) ) {
return new WP_Error ( 'sirius_bad_purpose' , __ ( 'Unknown sign-in purpose.' , 'sirius-press' ) );
}
$issued = self :: inspect ( $nonce );
if ( is_wp_error ( $issued ) ) {
return $issued ;
}
if ( self :: is_spent ( $nonce ) ) {
return new WP_Error ( 'sirius_replay' , __ ( 'That signature has already been used. Reload the page and sign again.' , 'sirius-press' ) );
}
$raw = base64_decode ( ( string ) $signature , true );
if ( false === $raw || 65 !== strlen ( $raw ) ) {
return new WP_Error ( 'sirius_bad_signature' , __ ( 'That is not a wallet signature. It should be a short block of base64 text.' , 'sirius-press' ) );
}
$digest = SP_Message :: bip137_digest ( self :: message ( $nonce , $purpose ) );
$pubkey = SP_Secp256k1 :: recover ( $raw , $digest );
if ( '' === $pubkey ) {
return new WP_Error ( 'sirius_bad_signature' , __ ( 'That signature does not match the text this site asked you to sign.' , 'sirius-press' ) );
}
$address = SP_CashAddr :: from_public_key ( $pubkey , SP_Settings :: prefix () );
if ( '' === $address ) {
return new WP_Error ( 'sirius_bad_signature' , __ ( 'That signature could not be turned into an address.' , 'sirius-press' ) );
}
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
if ( '' !== $claimed ) {
$want = SP_CashAddr :: normalize ( $claimed );
if ( '' === $want ) {
return new WP_Error ( 'sirius_bad_address' , __ ( 'That is not a valid Bitcoin Cash address.' , 'sirius-press' ) );
}
if ( ! hash_equals ( $want , $address ) ) {
// The signature is well formed but over different bytes than
// this site asked for — a copy that lost a line, a wallet that
// rewrote the text, or a signature meant for something else.
return new WP_Error (
'sirius_address_mismatch' ,
__ ( 'That signature does not match the text this site asked you to sign. Copy the text again exactly as shown, including the blank lines, and sign it once more.' , 'sirius-press' )
);
}
}
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
self :: spend ( $nonce );
return $address ;
}
// ----------------------------------------------------------- single use
private static function spent_key ( $nonce ) {
return 'sirius_spent_' . substr ( hash ( 'sha256' , $nonce ), 0 , 32 );
}
private static function is_spent ( $nonce ) {
return ( bool ) get_transient ( self :: spent_key ( $nonce ) );
}
private static function spend ( $nonce ) {
// Outlives the challenge itself, so a nonce can never come back after
// its marker expires but before the signature would have gone stale.
set_transient ( self :: spent_key ( $nonce ), 1 , self :: TTL + 120 );
}
// ----------------------------------------------------------- rate limits
/**
* Throttle signature attempts per client .
*
* Signature recovery is the most expensive thing an unauthenticated
* visitor can ask this site to do — on a BCMath host it is a few hundred
* milliseconds of CPU each . Without a cap , the login endpoint is a free
* denial - of - service amplifier .
*
* @ return true | WP_Error
*/
public static function check_rate_limit ( $bucket = 'verify' , $max = 20 , $window = 300 ) {
$key = 'sirius_rl_' . $bucket . '_' . substr ( hash ( 'sha256' , self :: client_ip () . wp_salt () ), 0 , 24 );
$count = ( int ) get_transient ( $key );
if ( $count >= $max ) {
return new WP_Error (
'sirius_rate_limited' ,
__ ( 'Too many sign-in attempts from this address. Wait a few minutes and try again.' , 'sirius-press' ),
array ( 'status' => 429 )
);
}
set_transient ( $key , $count + 1 , $window );
return true ;
}
/**
* The client ' s address , as well as it can be known .
*
* Only proxy headers the site owner has explicitly vouched for are
* believed . Trusting `X-Forwarded-For` by default would let anyone reset
* their own rate limit by inventing a header .
*/
private static function client_ip () {
$remote = isset ( $_SERVER [ 'REMOTE_ADDR' ] ) ? sanitize_text_field ( wp_unslash ( $_SERVER [ 'REMOTE_ADDR' ] ) ) : '' ;
/**
* Filters whether forwarded - for headers may be believed .
*
* Set true only when this site is genuinely behind a proxy that
* overwrites the header — the docker - compose nginx in this repo does .
*
* @ param bool $trust
*/
if ( ! apply_filters ( 'sirius_press_trust_proxy' , defined ( 'SIRIUS_PRESS_TRUST_PROXY' ) && SIRIUS_PRESS_TRUST_PROXY ) ) {
return $remote ;
}
foreach ( array ( 'HTTP_CF_CONNECTING_IP' , 'HTTP_X_REAL_IP' , 'HTTP_X_FORWARDED_FOR' ) as $header ) {
if ( empty ( $_SERVER [ $header ] ) ) {
continue ;
}
$value = sanitize_text_field ( wp_unslash ( $_SERVER [ $header ] ) );
$first = trim ( explode ( ',' , $value )[ 0 ] );
if ( filter_var ( $first , FILTER_VALIDATE_IP ) ) {
return $first ;
}
}
return $remote ;
}
}