From 899c00e613800ef973a93ce8f83b3514992f1afa Mon Sep 17 00:00:00 2001
From: Sebastian Pipping
The functions in this section configure the built-in + protection against various forms of + billion laughs attacks.
+ ++/* Added in Expat 2.4.0. */ +XML_Bool XMLCALL +XML_SetBillionLaughsAttackProtectionMaximumAmplification(XML_Parser p, + float maximumAmplificationFactor); ++
+ Sets the maximum tolerated amplification factor
+ for protection against
+ billion laughs attacks
+ (default: 100.0)
+ of parser p to maximumAmplificationFactor, and
+ returns XML_TRUE upon success and XML_TRUE upon error.
+
+ amplification := (direct + indirect) / direct ++ .. while parsing, whereas +
direct is the number of bytes read from the primary document in parsing and
+ indirect is the number of bytes added by expanding entities and reading of external DTD files, combined.
+
+ For a call to XML_SetBillionLaughsAttackProtectionMaximumAmplification to succeed:
p must be a non-NULL root parser (without any parent parsers) andmaximumAmplificationFactor must be non-NaN and greater than or equal to 1.0.+ Note: + If you ever need to increase this value for non-attack payload, + please file a bug report. +
+ ++ Note: + Peak amplifications + of factor 15,000 for the entire payload and + of factor 30,000 in the middle of parsing + have been observed with small benign files in practice. + + So if you do reduce the maximum allowed amplification, + please make sure that the activation threshold is still big enough + to not end up with undesired false positives (i.e. benign files being rejected). +
++/* Added in Expat 2.4.0. */ +XML_Bool XMLCALL +XML_SetBillionLaughsAttackProtectionActivationThreshold(XML_Parser p, + unsigned long long activationThresholdBytes); ++
+ Sets number of output bytes (including amplification from entity expansion and reading DTD files)
+ needed to activate protection against
+ billion laughs attacks
+ (default: 8 MiB)
+ of parser p to activationThresholdBytes, and
+ returns XML_TRUE upon success and XML_TRUE upon error.
+
For a call to XML_SetBillionLaughsAttackProtectionActivationThreshold to succeed:
p must be a non-NULL root parser (without any parent parsers).+ Note: + If you ever need to increase this value for non-attack payload, + please file a bug report. +
+ ++ Note: + Activation thresholds below 4 MiB are known to break support for + DITA 1.3 payload + and are hence not recommended. +
+The functions in this section either obtain state information from -- 1.8.3.1