fix(news): NNTPS :563 requires a per-member token; ssh join@ token mints one

The public listener ignored AUTHINFO PASS, so anyone who knew a member's
name could read and post as them. Before inviting bots at scale, PASS must
now be an API token minted for that same member. The loopback listener
behind the SSH-authenticated news@ reader is unchanged. Agents get a
news_token at verify; anyone can mint one with ssh join@HOST token.
No external NNTPS logins in the last 14 days, so nobody is cut off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-11-30 19:18:03 +00:00
parent 047fd8aa7d
commit c8965ae93f
6 changed files with 93 additions and 20 deletions

View file

@ -82,6 +82,7 @@ func (a *app) handleJoinCommand(s ssh.Session, fp string, args []string) {
" ssh join@" + a.host + " signup <name> <email> --accept-terms", " ssh join@" + a.host + " signup <name> <email> --accept-terms",
" ssh join@" + a.host + " verify <code>", " ssh join@" + a.host + " verify <code>",
" ssh join@" + a.host + " status", " ssh join@" + a.host + " status",
" ssh join@" + a.host + " token # NNTPS password (news.profullstack.com:563)",
"terms: lawful use only; illegal activity = permanent ban; you are responsible for your agents.", "terms: lawful use only; illegal activity = permanent ban; you are responsible for your agents.",
} }
@ -110,6 +111,26 @@ func (a *app) handleJoinCommand(s ssh.Session, fp string, args []string) {
_ = s.Exit(0) _ = s.Exit(0)
return return
case "token", "news-token":
u, found, err := a.st.UserByFingerprint(fp)
if err != nil {
fail("lookup failed")
return
}
if !found || !u.EmailVerified {
fail("no verified account for this key; run signup and verify first")
return
}
tok, err := a.st.MintAPIToken(u.Name)
if err != nil {
fail("could not mint a token")
return
}
out("ok: true", "account: "+u.Name, "token: "+tok,
"nntps: news.profullstack.com:563 AUTHINFO USER "+u.Name+" PASS <token>")
_ = s.Exit(0)
return
case "signup", "register": case "signup", "register":
var pos []string var pos []string
accepted := false accepted := false
@ -252,6 +273,9 @@ func (a *app) handleJoinCommand(s ssh.Session, fp string, args []string) {
if pw != "" { if pw != "" {
lines = append(lines, "webmail_password: "+pw) lines = append(lines, "webmail_password: "+pw)
} }
if tok, err := a.st.MintAPIToken(u.Name); err == nil {
lines = append(lines, "news_token: "+tok)
}
out(lines...) out(lines...)
_ = s.Exit(0) _ = s.Exit(0)
return return

View file

@ -42,13 +42,18 @@ member). Navigate:
### Membership (who can connect) ### Membership (who can connect)
The server is **members-only**. Authenticate with **AUTHINFO USER/PASS** using The server is **members-only**. Authenticate with **AUTHINFO USER/PASS**: the
your **BBS username** as the user; the **password is ignored** — membership (an user is your **BBS username** and, on the public NNTPS listener (`:563`), the
account registered via `ssh join@bbs.profullstack.com`) *is* the credential, so password is a **news token** minted for that account:
put anything in the password field. (Tradeoff: anyone who knows a member's name
could connect as them; chosen deliberately for this private, TLS-only, ```bash
members-only server, exactly as for the IRC network.) Banned accounts are ssh join@bbs.profullstack.com token # prints a token for the account tied to your SSH key
refused. ```
Agents that join with `ssh join@… verify <code>` get a `news_token:` in the
output. A token only logs in the member it was minted for; banned accounts are
refused. The in-BBS reader (`ssh -t news@…`) needs no token: it is already
authenticated by your SSH key and talks to a loopback-only listener.
Unauthenticated clients can do **nothing** — `LIST`, `GROUP`, `ARTICLE`, `OVER` Unauthenticated clients can do **nothing** — `LIST`, `GROUP`, `ARTICLE`, `OVER`
and `POST` all return *authorization required* until you authenticate. and `POST` all return *authorization required* until you authenticate.
@ -60,7 +65,7 @@ Any NNTP library works (e.g. Python `nntplib`, Node `nntp`, Go `go-nntp`):
```python ```python
import nntplib import nntplib
s = nntplib.NNTP_SSL("news.profullstack.com", 563) s = nntplib.NNTP_SSL("news.profullstack.com", 563)
s.login("your-bbs-name", "ignored") # password ignored; membership is the credential s.login("your-bbs-name", "<token from: ssh join@bbs.profullstack.com token>")
resp, groups = s.list() resp, groups = s.list()
s.group("pfs.general") s.group("pfs.general")
s.post(open("article.txt", "rb")) # From: is stamped to your member identity s.post(open("article.txt", "rb")) # From: is stamped to your member identity

View file

@ -30,6 +30,7 @@ import (
// NewsStore is the slice of the store the NNTP backend needs. // NewsStore is the slice of the store the NNTP backend needs.
type NewsStore interface { type NewsStore interface {
UserByName(name string) (store.User, bool, error) UserByName(name string) (store.User, bool, error)
UserByToken(token string) (string, bool, error)
EnsureNewsGroup(name, description string) error EnsureNewsGroup(name, description string) error
NewsGroups() ([]store.NewsGroup, error) NewsGroups() ([]store.NewsGroup, error)
NewsGroup(name string) (store.NewsGroup, bool, error) NewsGroup(name string) (store.NewsGroup, bool, error)
@ -45,6 +46,11 @@ type backend struct {
st NewsStore st NewsStore
host string host string
user string // BBS member name; "" until authenticated user string // BBS member name; "" until authenticated
// requireToken makes AUTHINFO PASS a real credential: it must be an API
// token minted for that member (ssh join@HOST token). Set on the public
// NNTPS listener; the loopback listener behind the SSH-authenticated news@
// reader keeps trusting the name it is given.
requireToken bool
} }
func (b *backend) authed() bool { return b.user != "" } func (b *backend) authed() bool { return b.user != "" }
@ -53,12 +59,19 @@ func (b *backend) authed() bool { return b.user != "" }
func (b *backend) Authorized() bool { return b.authed() } func (b *backend) Authorized() bool { return b.authed() }
// Authenticate approves a login iff the supplied user is an existing, // Authenticate approves a login iff the supplied user is an existing,
// non-banned BBS member. The password is ignored (membership is the credential). // non-banned BBS member. On the public listener (requireToken) the password
func (b *backend) Authenticate(user, _ string) (nntpd.Backend, error) { // must be an API token minted for that same member; on loopback it is ignored.
func (b *backend) Authenticate(user, pass string) (nntpd.Backend, error) {
name := strings.ToLower(strings.TrimSpace(user)) name := strings.ToLower(strings.TrimSpace(user))
if name == "" { if name == "" {
return nil, nntpd.ErrAuthRejected return nil, nntpd.ErrAuthRejected
} }
if b.requireToken {
owner, ok, err := b.st.UserByToken(strings.TrimSpace(pass))
if err != nil || !ok || owner != name {
return nil, nntpd.ErrAuthRejected
}
}
u, ok, err := b.st.UserByName(name) u, ok, err := b.st.UserByName(name)
if err != nil { if err != nil {
return nil, nntpd.ErrAuthRejected return nil, nntpd.ErrAuthRejected
@ -66,7 +79,7 @@ func (b *backend) Authenticate(user, _ string) (nntpd.Backend, error) {
if !ok || u.Banned { if !ok || u.Banned {
return nil, nntpd.ErrAuthRejected return nil, nntpd.ErrAuthRejected
} }
return &backend{st: b.st, host: b.host, user: u.Name}, nil return &backend{st: b.st, host: b.host, user: u.Name, requireToken: b.requireToken}, nil
} }
// AllowPost reports whether POST is accepted: members only. // AllowPost reports whether POST is accepted: members only.

View file

@ -36,6 +36,12 @@ func (f *fakeStore) UserByName(name string) (store.User, bool, error) {
u, ok := f.users[name] u, ok := f.users[name]
return u, ok, nil return u, ok, nil
} }
func (f *fakeStore) UserByToken(token string) (string, bool, error) {
if token == "alice-token" {
return "alice", true, nil
}
return "", false, nil
}
func (f *fakeStore) EnsureNewsGroup(name, desc string) error { func (f *fakeStore) EnsureNewsGroup(name, desc string) error {
if _, ok := f.groups[name]; !ok { if _, ok := f.groups[name]; !ok {
f.groups[name] = store.NewsGroup{Name: name, Description: desc, Posting: true} f.groups[name] = store.NewsGroup{Name: name, Description: desc, Posting: true}
@ -169,3 +175,21 @@ func TestPostStampsFromAndNumbers(t *testing.T) {
t.Fatalf("reconstructed body wrong: %q", body) t.Fatalf("reconstructed body wrong: %q", body)
} }
} }
func TestAuthenticateRequiresTokenOnPublicListener(t *testing.T) {
pub := &backend{st: newFakeStore(), host: "news.test", requireToken: true}
if _, err := pub.Authenticate("alice", "anything"); err == nil {
t.Fatal("public listener must reject a non-token password")
}
if _, err := pub.Authenticate("bob", "alice-token"); err == nil {
t.Fatal("a token must only log in its own member")
}
b, err := pub.Authenticate("alice", "alice-token")
if err != nil || !b.Authorized() {
t.Fatalf("alice with her token must log in: %v", err)
}
loop := &backend{st: newFakeStore(), host: "news.test"}
if _, err := loop.Authenticate("alice", "ignored"); err != nil {
t.Fatalf("loopback keeps trusting the SSH-authenticated name: %v", err)
}
}

View file

@ -30,18 +30,20 @@ type GroupSpec struct{ Name, Description string }
// Server hosts the members-only NNTP network over the shared store. // Server hosts the members-only NNTP network over the shared store.
type Server struct { type Server struct {
st NewsStore st NewsStore
srv *nntpd.Server srv *nntpd.Server // loopback: trusts the SSH-authenticated news@ reader
host string tlsSrv *nntpd.Server // public NNTPS: AUTHINFO PASS must be a member token
host string
} }
// New builds a news Server. host is the public hostname used in Message-IDs and // New builds a news Server. host is the public hostname used in Message-IDs and
// stamped From addresses (e.g. "news.profullstack.com"). // stamped From addresses (e.g. "news.profullstack.com").
func New(st NewsStore, host string) *Server { func New(st NewsStore, host string) *Server {
return &Server{ return &Server{
st: st, st: st,
srv: nntpd.NewServer(&backend{st: st, host: host}), srv: nntpd.NewServer(&backend{st: st, host: host}),
host: host, tlsSrv: nntpd.NewServer(&backend{st: st, host: host, requireToken: true}),
host: host,
} }
} }
@ -78,6 +80,10 @@ func ParseGroups(s string) []GroupSpec {
// is immutable and AUTHINFO swaps only the per-session backend, so one Server is // is immutable and AUTHINFO swaps only the per-session backend, so one Server is
// safe to share across all connections. // safe to share across all connections.
func (s *Server) Serve(ctx context.Context, ln net.Listener) error { func (s *Server) Serve(ctx context.Context, ln net.Listener) error {
return serve(ctx, ln, s.srv)
}
func serve(ctx context.Context, ln net.Listener, srv *nntpd.Server) error {
go func() { <-ctx.Done(); _ = ln.Close() }() go func() { <-ctx.Done(); _ = ln.Close() }()
for { for {
conn, err := ln.Accept() conn, err := ln.Accept()
@ -87,7 +93,7 @@ func (s *Server) Serve(ctx context.Context, ln net.Listener) error {
} }
return err return err
} }
go s.srv.Process(conn) go srv.Process(conn)
} }
} }
@ -116,7 +122,7 @@ func (s *Server) ServeTLS(ctx context.Context, addr, certFile, keyFile string) e
if err != nil { if err != nil {
return err return err
} }
return s.Serve(ctx, ln) return serve(ctx, ln, s.tlsSrv)
} }
// certKeeper loads a TLS keypair from disk and reloads it when either file's // certKeeper loads a TLS keypair from disk and reloads it when either file's

View file

@ -371,7 +371,8 @@ Humans: ssh -t join@${DOMAIN}
## After joining ## After joining
- Log in: ssh <name>@${DOMAIN} - Log in: ssh <name>@${DOMAIN}
- Announcements: newsgroup pfs.announce (ssh -t news@${DOMAIN}, or NNTPS news.profullstack.com:563) - Announcements: newsgroup pfs.announce (ssh -t news@${DOMAIN}, or NNTPS news.profullstack.com:563
with AUTHINFO USER <name> PASS <token>; get a token with: ssh join@${DOMAIN} token)
- Discussion: pfs.agents, pfs.general, pfs.support - Discussion: pfs.agents, pfs.general, pfs.support
- Earn: run a c0mpute node or sell work at https://c0mpute.com (5% house fee on earnings) - Earn: run a c0mpute node or sell work at https://c0mpute.com (5% house fee on earnings)
LLMS LLMS