Summary
WPCC reported "Unsanitized superglobal read ($_GET/$_POST)" as PASSED when the codebase contains raw $_POST usage without sanitization.
Scanned: Universal Child Theme 2024 (~12K LOC)
WPCC Version: 2.0.14
🔴 Missed Detection
Location: functions.php line 660
function fetch_search_data() {
$response = new stdClass();
$keyword = $_POST['keyword']; // ❌ No isset(), no sanitization
$prod_args = array(
'post_type' => 'product',
's' => $keyword, // ← Raw user input goes into WP_Query
'posts_per_page' => 3,
);
$prod_search = new WP_Query($prod_args);
// ...
}
What WPCC reported:
{"name": "Unsanitized superglobal read ($_GET/$_POST)", "status": "passed", "findings_count": 0}
Additional Instance
Location: functions.php line 930
$selected_value = isset( $_GET['wholesale_sales_rep'] ) ? $_GET['wholesale_sales_rep'] : '';
echo '<option value="' . $value . '" ' . selected( $selected_value, $value, false ) . '>';
Here isset() is present but no sanitization before passing to selected(). While selected() does comparison only (lower risk), this is still unsanitized superglobal usage.
Why This Matters
- Line 660 is in a public AJAX handler (
wp_ajax_nopriv_fetch_search_data)
- No isset() check - will throw PHP notice if
$_POST['keyword'] not set
- Raw input into WP_Query - while WP_Query's
s parameter is relatively safe, this pattern is dangerous
Possible Detection Pattern Issue
The current pattern may require specific contexts (direct echo, database query) and miss:
- Simple variable assignment:
$var = $_POST['key'];
- Assignment followed by use in function arguments
Current check might look for:
echo $_POST['x']; // Caught
$wpdb->query($_GET['x']); // Caught
But miss:
$keyword = $_POST['keyword']; // Not caught
do_something($keyword); // Dangerous use later
Suggested Detection Approach
Flag any $_GET/$_POST/$_REQUEST that:
- Is assigned to a variable without
sanitize_*, esc_*, absint(), intval(), etc. on the same line
- OR is used directly in function arguments without sanitization wrapper
Suggested pattern:
# Match: $var = $_POST['key'] without sanitize wrapper
\$\w+\s*=\s*\$_(GET|POST|REQUEST)\s*\[(?!.*sanitize_|.*esc_|.*absint|.*intval)
Suggested Test Fixture
// fixtures/unsanitized-superglobal-assignment.php
// Expected: FAIL - Unsanitized superglobal
function process_form() {
$name = $_POST['name']; // ❌ Should flag
$id = $_GET['id']; // ❌ Should flag
$safe = sanitize_text_field($_POST['email']); // ✅ OK
return $name . $id;
}
Summary
WPCC reported "Unsanitized superglobal read ($_GET/$_POST)" as PASSED when the codebase contains raw
$_POSTusage without sanitization.Scanned: Universal Child Theme 2024 (~12K LOC)
WPCC Version: 2.0.14
🔴 Missed Detection
Location:
functions.phpline 660What WPCC reported:
{"name": "Unsanitized superglobal read ($_GET/$_POST)", "status": "passed", "findings_count": 0}Additional Instance
Location:
functions.phpline 930Here
isset()is present but no sanitization before passing toselected(). Whileselected()does comparison only (lower risk), this is still unsanitized superglobal usage.Why This Matters
wp_ajax_nopriv_fetch_search_data)$_POST['keyword']not setsparameter is relatively safe, this pattern is dangerousPossible Detection Pattern Issue
The current pattern may require specific contexts (direct echo, database query) and miss:
$var = $_POST['key'];Current check might look for:
But miss:
Suggested Detection Approach
Flag any
$_GET/$_POST/$_REQUESTthat:sanitize_*,esc_*,absint(),intval(), etc. on the same lineSuggested pattern:
Suggested Test Fixture