Skip to content

Clear AUTHINFO credentials before returning pooled buffers - #208

Merged
enteriaza merged 3 commits into
masterfrom
163-bug-security-authinfo-password-is-returned-to-arraypool-without-clearing
Oct 19, 2026
Merged

enteriaza merged 3 commits into
masterfrom
163-bug-security-authinfo-password-is-returned-to-arraypool-without-clearing

Conversation

@enteriaza

Copy link
Copy Markdown
Collaborator

Summary

Fix credential exposure in NntpProviderSession.WritePrefixedAsync, where AUTHINFO PASS command buffers were returned to ArrayPool<byte>.Shared without clearing their contents.

Password bytes could remain in pooled memory after authentication, potentially exposing them to subsequent renters within the same process.

Closes #163

Changes

  • Clear the populated command buffer after the awaited write completes, including when the write fails or is cancelled.
  • Return the rented command buffer with clearArray: true to clear the entire array, including unused capacity.
  • Clear the separate encoded credential byte array after use.
  • Preserve the existing asynchronous write lifetime, NNTP command framing, and production use of ArrayPool<byte>.Shared.
  • Add a test-controlled ArrayPool<byte> seam to verify cleanup deterministically.
  • Extend regression coverage for successful authentication, write failures, cancellation, CRLF framing, and credential redaction in debug logs.

Validation

  • Focused provider-session and wire-logging tests: 11 passed, 0 failed, 0 skipped
  • Full BackFillerService test suite: 1,265 passed, 0 failed, 0 skipped
  • Release x64 solution build: 0 warnings, 0 errors
  • Solution format verification: passed
  • Local CodeQL security-and-quality scan: 171 queries completed successfully

Security verification

Tests use a controlled pool to inspect the buffer at return time, avoiding reliance on nondeterministic reuse of the shared pool.

The tests verify that credential-bearing buffers are cleared on success, write failure, and cancellation, and that debug logging redacts the password.

The local CodeQL scan reported no new result on NntpProviderSession.cs. GitHub's CodeQL scan has not yet run against this change.

Scope and limitations

This change prevents credentials from remaining in returned pooled buffers and clears the temporary encoded credential copy. The configured password string remains in memory for the session lifetime; this PR does not attempt to eliminate all in-memory representations of configured credentials.

Zero credential-bearing command buffers before returning them
to the array pool, including when writes fail or are cancelled.
Clear the separate encoded credential copy and add regression
coverage for buffer cleanup, wire framing, and log redaction.
@enteriaza enteriaza self-assigned this Oct 19, 2026
@enteriaza enteriaza added the bug Something isn't working label Oct 19, 2026
Capture structured per-attempt establishment outcomes, failure
reasons, elapsed times, and pool counts when concurrency assertions
fail. Preserve existing assertions and production behavior to help
diagnose intermittent Linux CI failures.
Replace the manually filtered loop with predicate-based Count
while preserving ordinal backbone matching and failure diagnostics.
@enteriaza
enteriaza merged commit 62cc7e2 into master Oct 19, 2026
7 checks passed
@enteriaza
enteriaza deleted the 163-bug-security-authinfo-password-is-returned-to-arraypool-without-clearing branch October 19, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug: Security] AUTHINFO password is returned to ArrayPool without clearing

2 participants