Skip to content

fix(sv1_api): keep the authorize password and connection URL out of formatted output - #2486

Open
amartya1523 wants to merge 3 commits into
stratum-mining:mainfrom
amartya1523:fix/sv1-redact-credentials
Open

amartya1523 wants to merge 3 commits into
stratum-mining:mainfrom
amartya1523:fix/sv1-redact-credentials

Conversation

@amartya1523

@amartya1523 amartya1523 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2473.

The authorize password and the info.connection-url from mining.configure (which can carry user:password@) reached formatted output in four ways:

  1. Authorize redacted the password in Display but derived Debug, and Error formats wrapped messages with {:?} (InvalidReceiver, Method).
  2. StandardRequest / Notification printed params as received in both Display and Debug. MethodError::ParsingMethodError keeps the raw Message, so every parse error of these two methods printed them.
  3. ParsingMethodError::WrongArgs / ValueNotAnArray kept the raw authorize params, and configure's ValueNotAnArray kept the raw configure params.
  4. InfoParams derived Debug, which Configure's Debug and Display both use, and IsServer logs debug!("{:?}", configure) on every configure.

Commit 1: raw requests. json_rpc::redact_params(method, params) replaces the credentials a request for method can carry with <redacted>. For mining.authorize that is every param after the worker name, or the whole value if params is not an array. For mining.configure it is any info.connection-url field. Other methods are borrowed untouched, so formatting mining.notify and friends allocates nothing new. StandardRequest and Notification use it in Display and in a hand-written Debug with the same shape as the derived one.

Commit 2: typed values and parse errors. Authorize and InfoParams get hand-written Debug impls that print <redacted>. The two authorize parse errors and the configure one keep redacted params instead of the raw ones.

Commit 3: sv1_api 7.0.0 → 7.0.1. Only formatting changes; the helper is pub(crate).

What stays visible: the worker name, hw/sw version and hw id, and every other method's params. Serialization (Serialize, From<…> for Message) is unchanged, so what goes on the wire is the same.

Tests:

  • Display and Debug of raw authorize requests (two params, extra params, object params, id: null) and of a configure with a connection URL contain <redacted> and not the secret.
  • Non-credential params are still printed.
  • An Error::InvalidReceiver wrapping an Authorize, and the Error from malformed authorize and configure requests, never contain the secret in Display or Debug.

Both redaction tests fail if redact_params is turned into a no-op.

StandardRequest and Notification printed their params as received, so
logging a mining.authorize showed its password, and logging a
mining.configure showed info.connection-url, which can embed
user:password@.

Add redact_params, which replaces those values with <redacted>, and use
it in the Display and Debug impls of both types. Other methods keep
their params as is.
…ebug

Authorize redacted its password in Display but derived Debug, and Error
formats wrapped messages with {:?}. InfoParams printed the connection
URL through Configure's Debug and Display, which IsServer logs on every
mining.configure. Parse errors of mining.authorize and mining.configure
also kept the raw params.

Write Debug for Authorize and InfoParams by hand, and redact the params
kept in those parse errors.
Only Display and Debug output changes, so sv1_api takes a patch bump.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Authorize password and configure connection URL show up in formatted output

1 participant