Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions docs/integrations/wordpress-vip/reviewed-exceptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@
"source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__",
"reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage."
},
{
"file": "webdecoy.php",
"function": "inject_js_verification_token",
"source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__",
"reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage."
},
{
"file": "webdecoy.php",
"function": "log_client_detection",
Expand Down
62 changes: 0 additions & 62 deletions webdecoy.php
Original file line number Diff line number Diff line change
Expand Up @@ -981,12 +981,6 @@ private function init_hooks(): void
add_action('plugins_loaded', [$this, 'register_wp_traps'], 20);
}

// JS execution verification: inject challenge token meta tag and report page serve
// Only active when scanner is enabled and API key is configured (premium)
if ($this->options['scanner_enabled'] && !is_admin() && $this->is_premium()) {
add_action('wp_head', [$this, 'inject_js_verification_token'], 1);
}

// Clear API cache when settings are saved
add_action('update_option_webdecoy_options', [$this, 'clear_api_status_cache']);

Expand Down Expand Up @@ -2868,62 +2862,6 @@ public function enqueue_clearance_client(): void
);
}

/**
* Inject JS execution verification challenge token into the page head.
* Generates a unique token per page view, embeds it as a meta tag, and
* reports it to the ingest service. bot-detection-pro.js reads the meta tag
* and beacons it back. If the beacon never arrives, the visitor is a non-JS scraper.
*/
public function inject_js_verification_token(): void
{
// Skip for logged-in users if scanner excludes them
if ($this->options['scanner_exclude_logged_in'] && is_user_logged_in()) {
return;
}

// Generate a unique challenge token (32 bytes hex = 64 chars)
$token = bin2hex(random_bytes(32));

// Output the meta tag in <head>
echo '<meta name="wd-ct" content="' . esc_attr($token) . '">' . "\n";

// Report page serve to ingest service (fire-and-forget)
$api_key = $this->options['api_key'];
if (empty($api_key)) {
return;
}

$collector = new \WebDecoy\SignalCollector($this->get_trusted_proxies());
$ip = $collector->getIP();

// phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : '';

// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$domain = isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : '';

// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$path = isset($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : '';

$payload = [
'token' => $token,
'domain' => $domain,
'path' => $path,
'ip' => $ip,
'user_agent' => $user_agent,
];

wp_remote_post('https://in.webdecoy.com/api/v1/page-serve', [
'timeout' => 1,
'blocking' => false,
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $api_key,
],
'body' => wp_json_encode($payload),
]);
}

private function scanner_enabled_for_visitor(): bool
{
return !empty($this->options['scanner_enabled'])
Expand Down
Loading