4 ms·
If the length is not pre-defined, the input has to be parsed to look for the closing tag. That makes your code vulnerable if the input tricks it into finding th
by sp332 9y ago
If the length is not pre-defined, the input has to be parsed to look for the closing tag. That makes your code vulnerable if the input tricks it into finding the wrong closing tag. But if the length is fixed, you don't have to parse it at all. That would avoid a whole class of vulnerabilities.
- dgoldstein 9y agoTrue, assuming that programmers don't compute code (HTML,SQL, etc) from user input and miscompute the length of a fragment. It would be interesting to see if this idea could work in practice.
- DCoder 9y agoA simple example could be the Twitter API's handling for references (URLs/hashtags/at-user mentions) in a tweet [0]. The tweet text is returned in one field, and all references are listed in a different field together with first/last character index within the tweet where that reference was found. You don't need to parse the tweet text yourself, just display it as plain text and insert links where the references say you should. [0]: https://dev.twitter.com/overview/api/entities-in-twitter-objects#the-urls-entity https://dev.twitter.com/overview/api/entities-in-twitter-obj...
- mike_hearn 9y agoThis isn't some theoretical design. Any native application that uses a binary protocol framework like protobufs over TCP to communicate with the backend will benefit from this approach.
- mwcampbell 9y ago> protobufs over TCP I guess it would have to be protobufs over TLS, and abuse port 443, to get through firewalls from hell.