Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
8e92cec
Merge remote-tracking branch 'v3.0_pgsql-auth-5863' into feature/pgsq…
rahim-kanji Jul 30, 2026
6b4f255
Merge remote-tracking branch 'v3.0' into feature/pgsql-native-backend…
rahim-kanji Jul 30, 2026
fd7a093
spec(pgsql): adversarial test coverage for the native backend protocol
rahim-kanji Aug 3, 2026
7191b02
spec(pgsql): review corrections — withdraw D2, qualify D3/D4, add gro…
rahim-kanji Aug 3, 2026
7043540
fix(pgsql): use the live backend connection when clearing named portals
rahim-kanji Aug 4, 2026
03dd798
fix(pgsql): reclaim consumed bytes in the native backend framer
rahim-kanji Aug 4, 2026
aeb823b
test(pgsql): assert the native framer reclaims consumed bytes
rahim-kanji Aug 10, 2026
0d26cbb
fix(pgsql): treat a torn-down native backend connection as non-reusable
rahim-kanji Aug 10, 2026
e56e15b
fix(pgsql): complete SCRAM-SHA-256-PLUS channel binding on the native…
rahim-kanji Aug 11, 2026
84db5a6
fix(pgsql): give native backend connections their own TLS session
rahim-kanji Aug 13, 2026
8b7477c
feat(pgsql): add backend_pid and using_ssl to stats_pgsql_free_connec…
rahim-kanji Aug 13, 2026
d3a03ca
test(pgsql): regression test for pooled native TLS losing its encryption
rahim-kanji Aug 14, 2026
c4341c7
Merge remote-tracking branch 'v3.0' into feature/review-pgsql-native-…
rahim-kanji Aug 17, 2026
d8ef3f4
docs(pgsql): correct the cbind buffer sizing comment in libscram
rahim-kanji Aug 17, 2026
faf7719
test(tap): register two pgsql unit tests
rahim-kanji Aug 17, 2026
b7bcbdf
fix(pgsql): don't abort when the backend connection is lost mid-result
rahim-kanji Aug 18, 2026
d00ce2c
fix(pgsql): treat an invalid backend reply sequence as an error, not …
rahim-kanji Aug 18, 2026
bdfec4f
test(pgsql): add regression test for backend connection lost mid-result
rahim-kanji Aug 18, 2026
281af8b
test(pgsql): cover backend lost mid-result against a real PostgreSQL
rahim-kanji Aug 18, 2026
e6278fb
test(pgsql): add regression test for an invalid backend reply sequence
rahim-kanji Aug 18, 2026
2df9d2f
Merge remote-tracking branch 'v3.0_pgsql-auth-5863' into feature/revi…
rahim-kanji Aug 18, 2026
8fff29c
Merge remote-tracking branch 'feature/pgsql-native-backend-protocol' …
rahim-kanji Aug 18, 2026
978b95c
Merge remote-tracking branch 'v3.0_pgsql-auth-5863' into feature/revi…
rahim-kanji Aug 18, 2026
fc99c3d
docs(pgsql): note that D3 was fixed within PR #6112
rahim-kanji Aug 19, 2026
5f7c9ff
Merge remote-tracking branch 'origin/feature/pgsql-native-backend-pro…
renecannao Aug 19, 2026
bda5955
fix(pgsql): harden the mid-result guard against a failed read on a li…
rahim-kanji Aug 20, 2026
8969c09
fix(pgsql): fold the mid-result guards into one and guarantee the error
rahim-kanji Aug 20, 2026
39af9d4
fix(pgsql): quarantine a connection that answers a query out of protocol
rahim-kanji Aug 20, 2026
1c56c54
test(pgsql): prove the protocol-violation quarantine end to end
rahim-kanji Aug 20, 2026
8a5d40d
test(pgsql): make the mid-result scenarios verifiable and bound their…
rahim-kanji Aug 20, 2026
db8a7ce
test(pgsql): fix the monitor-crash window and the review findings in …
rahim-kanji Aug 21, 2026
7543079
Merge remote-tracking branch 'feature/review-pgsql-native-backend-pro…
rahim-kanji Aug 21, 2026
2c448ab
Merge remote-tracking branch 'v3.0_pgsql-auth-5863' into feature/revi…
rahim-kanji Aug 21, 2026
8336d4e
Merge remote-tracking branch 'v3.0' into v3.0_fix-pgsql-backend-reply…
rahim-kanji Aug 21, 2026
50f093a
test(pgsql): make the query-cache scenario prove it ran
rahim-kanji Aug 21, 2026
71a9c95
Merge branch 'v3.0_fix-pgsql-backend-reply-handling-6109-6110' into f…
rahim-kanji Aug 21, 2026
04bb225
fix(pgsql): tear down a native backend connection that fails mid-result
rahim-kanji Aug 22, 2026
47bcc14
Added comment
rahim-kanji Aug 24, 2026
c4537e2
test(pgsql): cover the native framer bounds, sticky errors and fragme…
rahim-kanji Aug 24, 2026
840498b
test(pgsql): drive the native backend path against a hostile PostgreSQL
rahim-kanji Aug 25, 2026
b5db822
test(pgsql): drop runtime-variable restore from the two native mock t…
rahim-kanji Aug 25, 2026
3de165f
fix(pgsql): stop session introspection from aborting the proxy on a n…
rahim-kanji Aug 25, 2026
5e6c06c
test(pgsql): cover PROXYSQL INTERNAL SESSION on the native backend path
rahim-kanji Aug 25, 2026
6d404b0
fix(pgsql): report client_encoding and server_version correctly on a …
rahim-kanji Aug 25, 2026
834affd
test(pgsql): cover the connection metadata reported for a native backend
rahim-kanji Aug 25, 2026
54acb29
Merge branch 'v3.0_pgsql_terminate_conn_leak_6129' into feature/revie…
rahim-kanji Aug 26, 2026
e23c4bd
feat(pgsql): carry the session settings in the native StartupMessage
rahim-kanji Aug 28, 2026
f2eed5b
test(pgsql): cover the session settings carried in the native Startup…
rahim-kanji Aug 28, 2026
899e977
ci: retrigger PR 6112 checks
renecannao Aug 30, 2026
6124281
ci: fix groups.json ordering
renecannao Aug 30, 2026
da61452
fix(pgsql): forward DEALLOCATE of a SQL-prepared statement to the bac…
rahim-kanji Aug 31, 2026
b567859
test(pgsql): cover DEALLOCATE forwarding of a SQL-prepared statement
rahim-kanji Aug 31, 2026
c5d6877
DEALLOCATE ALL: Exact match, not a prefix
rahim-kanji Aug 31, 2026
55d6f82
test(pgsql): DEALLOCATE ALL, Exact match, not a prefix
rahim-kanji Aug 31, 2026
dcf7195
fix(pgsql): free SQL-prepared statements on DEALLOCATE ALL
rahim-kanji Sep 1, 2026
a722b7f
test(pgsql): cover DEALLOCATE ALL forwarding and the aborted-txn guard
rahim-kanji Sep 1, 2026
7794ce9
fix(pgsql): pin the query end state in ASYNC_QUERY_START
rahim-kanji Sep 1, 2026
174aa6e
test(pgsql): cover the native variable-sync hang
rahim-kanji Sep 1, 2026
5bc8453
Merge remote-tracking branch 'feature/review-pgsql-native-backend-pro…
rahim-kanji Sep 2, 2026
18a8e6a
Merge remote-tracking branch 'v3.0_pgsql-auth-5863' into feature/revi…
rahim-kanji Sep 3, 2026
c909215
Merge branch 'feature/pgsql-native-backend-protocol' into feature/rev…
rahim-kanji Sep 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions deps/libscram/src/scram.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,21 +502,34 @@ char *build_client_first_message(ScramState *scram_state)
goto failed;
scram_state->client_nonce[encoded_len] = '\0';

len = 8 + strlen(scram_state->client_nonce) + 1;
result = malloc(len);
if (result == NULL)
goto failed;
if (scram_state->client_cbind_input != NULL) {
/* Channel-bound client: gs2 cbind flag 'p' with tls-server-end-point
* type. The PostgreSQL convention is an empty SCRAM username (the
* real username travels in the StartupMessage), so the header is
* "p=tls-server-end-point,,". */
snprintf(result, len, "p=tls-server-end-point,,n=,r=%s", scram_state->client_nonce);
} else {
snprintf(result, len, "n,,n=,r=%s", scram_state->client_nonce);
}
/* gs2 header: "n,," for plain SCRAM, "p=tls-server-end-point,," when the
* caller installed a channel-binding input (SCRAM-SHA-256-PLUS). Its length
* drives BOTH the allocation and the offset used to derive
* client_first_message_bare, so the two cannot disagree.
*
* Previously the buffer was sized for the 8-char plain prefix "n,,n=,r=",
* which silently truncated the 29-char channel-bound message, and the bare
* message was taken as "result + 3", which skipped only 3 of the 24 header
* bytes and corrupted the AuthMessage the client proof is computed over.
*
* The PostgreSQL convention is an empty SCRAM username (the real username
* travels in the StartupMessage), hence "n=".
*/
{
const char *gs2 = (scram_state->client_cbind_input != NULL)
? "p=tls-server-end-point,," : "n,,";
const size_t gs2_len = strlen(gs2);

/* gs2 + "n=,r=" (5) + nonce + NUL. For the plain header this is
* 3 + 5 + nonce + 1, identical to the previous 8 + nonce + 1. */
len = gs2_len + 5 + strlen(scram_state->client_nonce) + 1;
result = malloc(len);
if (result == NULL)
goto failed;
snprintf(result, len, "%sn=,r=%s", gs2, scram_state->client_nonce);

scram_state->client_first_message_bare = strdup(result + 3);
scram_state->client_first_message_bare = strdup(result + gs2_len);
}
if (scram_state->client_first_message_bare == NULL)
goto failed;

Expand Down Expand Up @@ -545,9 +558,11 @@ char *build_client_final_message(ScramState *scram_state,

if (scram_state->client_cbind_input != NULL) {
/* Channel-bound client: c=base64(gs2-header || cbind-data).
* 86 bytes buffer = 22 (header) + 64 (max digest we accept) = 86;
* base64-encoded = 116 chars max. The full prefix
* "c=<b64>,r=<server_nonce>" easily fits in 512. */
* The gs2 header "p=tls-server-end-point,," is 24 bytes, so the
* cbind input is at most 24 + 64 (max digest we accept) = 88 bytes;
* base64-encoded = 4*ceil(88/3) = 120 chars, 121 with the NUL that
* is written below -- so b64[128] has 7 bytes of headroom. The full
* prefix "c=<b64>,r=<server_nonce>" easily fits in 512. */
char b64[128];
int blen = pg_b64_encode(scram_state->client_cbind_input,
scram_state->client_cbind_input_len,
Expand Down
Loading
Loading