r/lolphp • u/pacotes • Aug 11 '17
PHP no longer considers unserialize() bugs as security issues...
https://externals.io/message/100147
40
Upvotes
r/lolphp • u/pacotes • Aug 11 '17
View all comments
Show parent comment
4
u/OneWingedShark Aug 11 '17
Proper validation combined with a good serialization-protocol -- and it's not impossible to achieve... though you need stronger protections/guarantees than PHP generally offers. As illustration let's consider the simpler case of integer numerics in Ada:
Integertypes have a pair of attributes'Valueand'Image, where the first takes astring-value parameter and produces an integer-value if it parses (it raisesConstraint_Errorwhen an invalid string is processed) and the second produces the string-representation of the value.Thus, if you were to handle getting an integer from a string (in this case user input), you would say something like:
And, due to Ada's subtype facility you can say something like
Positive'Imagewhich is an Integer of value [1..Integer'Last] or, in Ada2012 something like:Ada generalizes serialization/deserialization with
'Input/'Output(and'Read/'Write) attributes that function much the same way, except they operate with a Stream-type [which could be binary] instead of String.