@anonympins/fingerprint 0.5.5 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +7 -6
- package/package.json +1 -1
- package/public/fp.js +1 -1
- package/public/fp.wasm +0 -0
- package/src/js/build-client.js +1 -1
- package/src/js/fingerprint.client.js +19 -5
- package/src/js/fingerprint.client.obfuscated.js +1 -1
- package/src/js/fingerprint.js +430 -74
- package/src/js/problem-manager.js +22 -0
- package/src/js/tests/cross_parity.test.js +17 -11
- package/src/js/tests/fingerprint.client.test.js +130 -128
- package/src/js/tests/fingerprint.test.js +17 -2
- package/src/js/ttl-optimization.worker.js +51 -0
- package/src/php/Challenge/ChallengeUtils.php +120 -8
- package/src/php/FingerprintBuilder.php +193 -185
- package/src/php/FingerprintEngine.php +245 -3
- package/src/php/ProblemManager.php +20 -0
- package/src/php/RequestContext.php +2 -0
- package/src/php/Tests/ChallengeUtilsTest.php +446 -285
- package/src/php/Utils/RequestUtils.php +26 -1
|
@@ -201,6 +201,16 @@ class ProblemManager
|
|
|
201
201
|
error_log("[ProblemManager] Aucune fonction de score définie pour {$problemId}.");
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
|
+
// DoS mitigation: validate solution size and structure
|
|
205
|
+
if (is_array($solutionData['solution']) && count($solutionData['solution']) > 500) {
|
|
206
|
+
error_log("[ProblemManager] Solution array too large for {$problemId} verification.");
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
$serializedSolution = json_encode($solutionData['solution']);
|
|
210
|
+
if ($serializedSolution !== false && strlen($serializedSolution) > 65536) {
|
|
211
|
+
error_log("[ProblemManager] Solution payload size exceeds safe limit for {$problemId}.");
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
204
214
|
// 1. Ne JAMAIS faire confiance au score du client. Recalculer systématiquement.
|
|
205
215
|
$recalculatedEnergy = $scoreFunction($solutionData['solution'], $problem['payload'] ?? []);
|
|
206
216
|
|
|
@@ -218,6 +228,16 @@ class ProblemManager
|
|
|
218
228
|
break;
|
|
219
229
|
case 'genetic_algorithm_generations':
|
|
220
230
|
if (isset($solutionData['population']) && is_array($solutionData['population'])) {
|
|
231
|
+
if (count($solutionData['population']) > 150) {
|
|
232
|
+
error_log("[ProblemManager] Population size exceeds safe limit for {$problemId}.");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
foreach ($solutionData['population'] as $ind) {
|
|
236
|
+
if (isset($ind['chromosome']) && is_array($ind['chromosome']) && count($ind['chromosome']) > 100) {
|
|
237
|
+
error_log("[ProblemManager] Chromosome size too large for {$problemId}.");
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
221
241
|
$problem['state']['population'] = $solutionData['population'];
|
|
222
242
|
$problem['state']['lastUpdate'] = (new \DateTime())->format(\DateTime::ATOM);
|
|
223
243
|
$stateChanged = true;
|
|
@@ -40,6 +40,7 @@ class RequestContext
|
|
|
40
40
|
public ?string $http2Fingerprint = null;
|
|
41
41
|
public ?string $quicFingerprint = null;
|
|
42
42
|
public ?string $tcpFingerprint = null;
|
|
43
|
+
public ?string $zkpY = null; // NOUVEAU: Clé publique ZKP du client
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* @param string $clientIp
|
|
@@ -79,6 +80,7 @@ class RequestContext
|
|
|
79
80
|
$this->http2Fingerprint = $this->headers['x-http2-fingerprint'] ?? null;
|
|
80
81
|
$this->tcpFingerprint = $this->headers['x-tcp-fingerprint'] ?? null;
|
|
81
82
|
$this->quicFingerprint = $this->headers['x-quic-fp'] ?? null;
|
|
83
|
+
$this->zkpY = isset($this->headers['x-zkp-proof']) ? explode(':', $this->headers['x-zkp-proof'])[0] : null;
|
|
82
84
|
$this->tlsSessionId = $this->headers['x-tls-session-id'] ?? $this->headers['x-ssl-session-id'] ?? null;
|
|
83
85
|
}
|
|
84
86
|
/**
|