Skip to content

Commit 91f22e8

Browse files
committed
added function to report leaked server version from header field
Signed-off-by: Prateek rana <[email protected]>
1 parent d4d4b92 commit 91f22e8

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Server Header Check by freakyclown@gmail.com
2+
// Server Version leaks found via header field by prateek.rana@getastra.com
23

3-
function scan(ps, msg, src)
4-
{
4+
var VERSION_PATTERN = new RegExp("(?:\\d+\\.)+\\d+");
5+
6+
function scan(ps, msg, src) {
57

68
var alertRisk = 1
79
var alertConfidence = 2
@@ -15,9 +17,24 @@ function scan(ps, msg, src)
1517
var url = msg.getRequestHeader().getURI().toString();
1618
var headers = msg.getResponseHeader().getHeaders("Server")
1719

18-
if (headers != null)
20+
if (headers != null && containsPotentialSemver(headers))
1921
{
20-
ps.raiseAlert(alertRisk, alertConfidence, alertTitle, alertDesc, url, '', '', '', alertSolution,headers, cweId, wascId, msg);
22+
var headersString = headers.toString();
23+
ps.raiseAlert(alertRisk, alertConfidence, alertTitle, alertDesc, url, '', '', '', alertSolution, headersString, cweId, wascId, msg);
2124
}
2225

2326
}
27+
28+
function containsPotentialSemver(content) {
29+
try {
30+
var res = VERSION_PATTERN.exec(content);
31+
if (res == null || res.join('') === ""){
32+
return false;
33+
}
34+
return true;
35+
}
36+
37+
catch (err) {
38+
return false;
39+
}
40+
}

0 commit comments

Comments
 (0)