projectdiscovery/nuclei · error
invalid host or port
Error message
invalid host or port
What it means
Returned by mssql.FingerprintMssql when host is an empty string or port is <= 0. It is a pure input-validation failure raised before any network activity; everything else in the function (host allowlist check, dialer lookup, TDS probe) happens after this guard.
Source
Thrown at pkg/js/libs/mssql/fingerprint.go:107
// const mssql = require('nuclei/mssql');
// const info = mssql.FingerprintMssql('acme.com', 1433);
// log(to_json(info));
// ```
func (c *MSSQLClient) FingerprintMssql(ctx context.Context, host string, port int) (MSSQLInfo, error) {
executionId := ctx.Value("executionId").(string)
return memoizedfingerprintMssql(ctx, executionId, host, port)
}
// @memo
func fingerprintMssql(ctx context.Context, executionId string, host string, port int) (MSSQLInfo, error) {
info := MSSQLInfo{
Host: host,
Port: port,
Protocol: "mssql",
Transport: "tcp",
}
if host == "" || port <= 0 {
return info, fmt.Errorf("invalid host or port")
}
if !protocolstate.IsHostAllowed(executionId, host) {
return info, protocolstate.ErrHostDenied.Msgf(host)
}
dialer := protocolstate.GetDialersWithId(executionId)
if dialer == nil {
return info, fmt.Errorf("dialers not initialized for %s", executionId)
}
conn, err := dialer.Fastdialer.Dial(ctx, "tcp", net.JoinHostPort(host, fmt.Sprintf("%d", port)))
if err != nil {
return info, err
}
defer func() {
_ = conn.Close()
}()
_ = conn.SetDeadline(time.Now().Add(mssqlFingerprintTimeout))View on GitHub (pinned to 265b3a3dec)
Solutions
- Guard the call site: only fingerprint when host is non-empty and port is a positive integer
- Apply a sensible default port (1433) when the target is known to be MSSQL
- Parse host:port with split(':') and validate both halves before calling
Example fix
// before
mssql.FingerprintMssql(target, to_number(port)); // port empty -> 0 -> error
// after
if (target && to_number(port) > 0) {
mssql.FingerprintMssql(target, to_number(port));
} Defensive patterns
Strategy: validation
Validate before calling
const p = to_number(port || 1433);
if (!host || !(p > 0)) {
throw new Error('mssql fingerprint needs a non-empty host and positive port');
}
const info = mssql.FingerprintMssql(String(host), p); Type guard
const validHostPort = (h, p) => typeof h === 'string' && h !== '' && Number.isInteger(p) && p > 0;
Prevention
- Default the port to 1433 when the service is known to be MSSQL
- Validate extractor-derived host/port values before use
- Split host:port strings and check both halves are present
When it happens
Trigger: mssql.FingerprintMssql('', 1433); mssql.FingerprintMssql('acme.com', 0) — typically because the template derived the port from a variable/extractor that was empty and defaulted to 0, or parsed a host:port string and got an empty host.
Common situations: Templates that fingerprint 'on discovery' where the port is optional and frequently missing; passing a URL where the code expected a bare hostname; JS number coercion yielding NaN/0 for a non-numeric port string.
Related errors
- invalid host or port
- not a mssql service
- invalid goexec method arguments: %w
- parse target: %w
- grpc target host cannot be empty
AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15).
Data as JSON: /api/errors/24c87bac08f56660.
Report an issue: GitHub.