sqlmapproject/sqlmap · error · OperationalError
SCRAM server nonce does not extend the client nonce (rogue s
Error message
SCRAM server nonce does not extend the client nonce (rogue server?)
What it means
Error "SCRAM server nonce does not extend the client nonce (rogue server?)" thrown in sqlmapproject/sqlmap.
Source
Thrown at extra/dbwire/postgres.py:264
elif code == 10: # SASL (SCRAM-SHA-256)
if not hasattr(hashlib, "pbkdf2_hmac"):
raise NotSupportedError("SCRAM-SHA-256 authentication requires Python >= 2.7.8 (hashlib.pbkdf2_hmac)")
client_nonce = base64.b64encode(os.urandom(18)).decode("ascii")
cfirst_bare = "n=,r=%s" % client_nonce
client_first = "n,," + cfirst_bare
_send(sock, b"p", b"SCRAM-SHA-256\x00" + struct.pack("!I", len(client_first)) + client_first.encode("ascii"))
elif code == 11: # SASLContinue (server-first)
try:
server_first = payload[4:].decode("ascii")
attrs = dict(kv.split("=", 1) for kv in server_first.split(","))
snonce, salt, iterations = attrs["r"], base64.b64decode(attrs["s"]), int(attrs["i"])
except (KeyError, ValueError, binascii.Error, UnicodeDecodeError) as ex:
raise OperationalError("malformed SCRAM server-first message (%s)" % ex)
# RFC 5802 5.1: the server nonce MUST start with the client nonce and MUST add material of its
# own. Skipping this lets anything that can answer the TCP connection replay a recorded
# server-first and drive the exchange - and dbwire has no TLS layer underneath to catch it.
if not client_nonce or not snonce.startswith(client_nonce) or len(snonce) <= len(client_nonce):
raise OperationalError("SCRAM server nonce does not extend the client nonce (rogue server?)")
if iterations < 4096: # RFC 5802 recommends >= 4096; a tiny count cheapens an offline attack
raise OperationalError("SCRAM iteration count %d is too low" % iterations)
salted = hashlib.pbkdf2_hmac("sha256", (password or "").encode("utf-8"), salt, iterations)
client_key = hmac.new(salted, b"Client Key", hashlib.sha256).digest()
stored_key = hashlib.sha256(client_key).digest()
client_final_noproof = "c=biws,r=%s" % snonce
auth_message = "%s,%s,%s" % (cfirst_bare, server_first, client_final_noproof)
client_sig = hmac.new(stored_key, auth_message.encode("ascii"), hashlib.sha256).digest()
proof = base64.b64encode(_xor(client_key, client_sig)).decode("ascii")
_send(sock, b"p", ("%s,p=%s" % (client_final_noproof, proof)).encode("ascii"))
elif code == 12: # SASLFinal (server-final): verify the server too, or the handshake is one-way
# Without this the client proves itself to the server and simply trusts whatever answers back.
# ServerSignature = HMAC(ServerKey, AuthMessage) can only be produced by a peer that holds the
# stored credentials, so comparing it is what makes the exchange mutual (RFC 5802 5, 5.1).
if salted is None or auth_message is None:
raise OperationalError("unexpected SCRAM server-final message")
try:
attrs = dict(kv.split("=", 1) for kv in payload[4:].decode("ascii").split(","))View on GitHub (pinned to 0a35b20e39)
When it happens
Trigger: Thrown at extra/dbwire/postgres.py:264 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sqlmapproject/sqlmap@0a35b20e39 (2026-08-26).
Data as JSON: /api/errors/9491028c4808f9c7.
Report an issue: GitHub.