Skip to content

Commit 6dd9465

Browse files
Prateek1519kingthorin
authored andcommitted
added function to report leaked server version from header field
Signed-off-by: prateekrana-getastra <prateek.rana@getastra.com>
1 parent d4d4b92 commit 6dd9465

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1818
### Changed
1919
- standalone/enableDebugLogging.js > Updated for more recent logging funtionality.
2020
- Update JS scripts to use passed singleton variables (control, model, view) if available (>= ZAP 2.12.0).
21+
- passive/Server Header Disclosure.js > Updated to check that the Server Header contains something that looks like a semantic version component.
2122

2223
## [14] - 2021-11-01
2324
### Added

passive/Server Header Disclosure.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Server Header Check by freakyclown@gmail.com
2+
// Server Version leaks found via header field by prateek.rana@getastra.com
23

34
function scan(ps, msg, src)
45
{
@@ -15,9 +16,27 @@ function scan(ps, msg, src)
1516
var url = msg.getRequestHeader().getURI().toString();
1617
var headers = msg.getResponseHeader().getHeaders("Server")
1718

18-
if (headers != null)
19+
if (headers != null && containsPotentialSemver(headers))
1920
{
20-
ps.raiseAlert(alertRisk, alertConfidence, alertTitle, alertDesc, url, '', '', '', alertSolution,headers, cweId, wascId, msg);
21+
var headersString = headers.toString();
22+
ps.raiseAlert(alertRisk, alertConfidence, alertTitle, alertDesc, url, '', '', '', alertSolution, headersString, cweId, wascId, msg);
2123
}
2224

2325
}
26+
27+
function containsPotentialSemver(content) {
28+
29+
var versionPattern = new RegExp("(?:\\d+\\.)+\\d+");
30+
31+
try {
32+
var res = versionPattern.exec(content);
33+
if (res == null || res.join('') === ""){
34+
return false;
35+
}
36+
return true;
37+
}
38+
39+
catch (err) {
40+
return false;
41+
}
42+
}

0 commit comments

Comments
 (0)