Make stratum implementation align with ckpool #560
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
parasitepool/para#560
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
para too strict
else if (nlen < len) { /* Pad with zeros */ }
para: Strictly rejects with InvalidNonce2Length error
if submit.enonce2.len() != expected_extranonce2_size {
// Send error and reject share
}
ckpool: Silently truncates nonce to 8 characters
if (unlikely(nlen > len)) nonce[len] = '\0'; // len = 8
para: Strict hex parsing via Nonce::from_str
ckpool: Ignores invalid version_mask, uses 0
if (version_mask && strlen(version_mask) && validhex(version_mask)) {
// Only parse if valid
}
// Otherwise version_mask32 stays 0, no error
para: Strict deserialization fails on invalid version
ckpool: Accepts missing password (sets to "")
para: Also accepts (via Option)
para too lenient
ckpool: Requires nonce to be at least 8 hex characters
if (unlikely(!nonce || strlen(nonce) < 8 || !validhex(nonce))) {
err = SE_NO_NONCE; // Error if < 8 chars
}
para: Accepts any valid u32 hex (as short as "0")
let nonce = u32::from_str_radix(s, 16)?; // "0", "1", "abc" all valid
ckpool: Strictly rejects odd-length hex
if (!slen || slen % 2) // Rejects odd length
para: Some hex fields accept odd-length (we just fixed subscribe, but nonce/ntime/version still accept odd-length via from_str_radix)
ckpool: Rejects:
para: Accepts any string, only validates as Bitcoin address later
ckpool: Max 64 characters (strndup(pass, 64))
para: No explicit limit
ckpool: Rejects empty nonce strings
para: Would fail parsing but error message differs
Misc
Nonce2/Nonce Length Tolerance
ckpool auto-corrects malformed nonce2 and nonce values from miners:
(
wb->enonce2varlen), ckpool truncates silently. If longer, it alsotruncates.
nonce[len] = '\0'(stratifier.c:6059).para rejects immediately with
InvalidNonce2Lengthifenonce2.len() != expected_extranonce2_size(stratifier.rs:692). Nonce is deserialized witha fixed 4-byte type so invalid lengths fail at parse time.
Some miner firmware (especially older or buggy implementations) may send
slightly wrong lengths. ckpool silently handles this; para rejects the
share.
What ckpool does vs. what para now does
Concern ckpool para (this branch) Verdict
Workername length username[128] buffer; truncates at 127 Rejects >127 chars Ours stricter, deliberate (rejection beats silent rewriting)
Workername charset No filtering, bounded only Rejects control chars (ESC/DEL/newline/…) Ours stricter — this was the actual vuln
Password Bounded: strndup(pass, 64) Option, unbounded Different, not worse — see below
user_agent Stored raw (strdup), served back in admin JSON unfiltered, printed in logs Validated at Username boundary only if it were a username; user_agent itself unvalidated Below
Failed-auth backoff failed_authtime/auth_backoff throttling None Below
The two real candidate gaps — and why I recommend not fixing either
The one thing I'd flag as worth a look (but not necessarily a fix)
user_agent is the last unvalidated miner-supplied string. In ckpool it's stored raw and echoed into the admin clientlist JSON and logs — same class of issue as the workername was. In para it's captured at stratifier.rs:574 into Subscription.user_agent and… let me be precise: I traced it to state.rs but did not confirm whether it reaches logs or an HTTP response. If it stays purely in-memory and never hits a log line or dashboard, it's a non-issue (a string sitting in a struct can't hurt anyone). If it does surface anywhere rendered, it's the same ANSI-injection shape we just closed.
That determination is a two-minute read — rg "user_agent" src/api templates/. Want me to run it and report back before you decide? My recommendation: only act if it actually escapes to a log or response; otherwise leave it.
Everything else in the crate — the Authorize serde (untagged 1-or-2-arity), Submit.username re-validation, worker-mismatch compare — already routes through the hardened Username, so it's covered by this branch.