[FALSE-POSITIVE] smb-default-login reports credentials that were never validated on guest-mapping servers
Template IDs or paths
javascript/default-logins/smb-default-login.yaml
Environment
- OS: Linux
- Nuclei: v3.11.1
- Go: 1.25
Steps To Reproduce
Samba configured to map unknown users to guest, with nothing a guest can actually reach:
[global]
server role = standalone server
map to guest = Bad User
guest account = nobody
server min protocol = SMB2
[Backups]
path = /shares/backups
valid users = realuser
guest ok = no- Run
smb-default-loginagainst it. - It matches, reporting whichever credential pair the clusterbomb tried first.
Expected result: no match. None of the nine credential pairs is valid on this server.
Actual result: a high-severity default-credential finding. map to guest = Bad User completes SESSION_SETUP for any username, so the login being reported was never checked against anything. ListShares then succeeds for every pair and returns at least IPC$, because that is the pipe the enumeration itself travels over.
Same root cause as #7752 and nuclei-templates#17295, but the fix there does not transfer. The claim in that template is "a share is readable", so probing shares answers it. The claim here is "these credentials work", and no amount of share probing speaks to that.
Scale, measured on our production fleet: 141 findings across 101 tenants, 96 of them Samba on consumer NAS and appliances — QNAP, Synology, WD, routers, MFPs. map to guest = Bad User is the shipped default on a lot of them.
Relevant dumped responses
Not meaningful — SESSION_SETUP succeeds identically for a valid and an invalid credential, so the match carries nothing that distinguishes them.
Anything else?
Suggested fix, using today's API
Offer a credential that cannot exist. If that one also authenticates and enumerates, the credential under test proved nothing:
var m = require("nuclei/smb");
var c = new m.SMBClient();
// Constant rather than random: ListShares memoizes on
// (executionId, host, port, user, password), so a fixed canary costs one
// extra dial per host instead of one per payload pair.
var CANARY = "nuclei-canary-4f8a2c91b7e6";
var acceptsAnything = false;
try {
c.ListShares(Host, Port, CANARY, CANARY);
acceptsAnything = true;
} catch (e) {}
if (acceptsAnything) {
throw new Error("server authenticates any credential; the tested login was never validated");
}
var response = c.ListShares(Host, Port, User, Pass);
response;Two details that matter:
- The canary has to clear both hurdles, not just the login. A server that admits it as guest and then denies it the enumeration gave the tested credential something the canary did not have — which means the tested credential was validated after all.
- It has to be constant to hit the memo.
max-request: 9, so a random canary per payload is nine extra dials per host instead of one.
A throw is what suppresses the match: success is the goja truthiness of the returned value, so returning an empty value would not do it.
Control host — the fix must not break real detection
Same shape, guest mapping off, with a genuine admin/admin account. smb-default-login must keep firing here:
[global]
server role = standalone server
map to guest = Never
server min protocol = SMB2
[Data]
path = /shares/data
valid users = adminSecondary: one matcher clause is inert
- 'response != "[]"'This template does not call Export, so it takes the non-pooling path and response is a Go []string, not a string. Comparing a slice to the literal "[]" is true for every slice, empty or not — the clause never discriminates and the matcher reduces to success == true. Probably unreachable in practice, since a successful ListShares returns at least IPC$, but the clause is not doing what it reads as. Worth dropping rather than fixing, given the throw above is the real gate.
Relationship to #7760
That API supersedes this. Reading guest/null status from the completed session setup is one dial and reads the protocol's own answer instead of inferring it from a second login. The canary above is the template-only version that works before the goimpacket dependency lands — worth having in the meantime, given the finding volume.
Note on the guest/guest payload pair
It is in the list, and on any server with guest enabled it legitimately authenticates. With the canary in place it is correctly suppressed on guest-mapping servers. On a server where guest is explicitly enabled but unknown users are rejected it still fires — arguably correct, though it overlaps entirely with smb-anonymous-access. Flagging it as a design question, not a bug.
One difference from our own implementation, deliberately not proposed here
We additionally require the credential to reach a non-administrative share before reporting. That suppresses a valid-but-useless default credential, which is arguably a genuine finding — so it probably does not belong in the upstream template. Noting it only so the difference is visible if you compare.
Source: projectdiscovery/nuclei-templates