4 ms·
This is both surprising and unsurprising at the same time. I wonder how long until we collectively decide to banish things like ASN.1 to the past like we are d
by sneak 5y ago
This is both surprising and unsurprising at the same time.
I wonder how long until we collectively decide to banish things like ASN.1 to the past like we are doing with C strings and parsing of untrusted network input in memory unsafe languages.
ASN.1: unsafe at any speed.
See also: https://en.m.wikipedia.org/wiki/X.690 https://en.m.wikipedia.org/wiki/X.690
Everything I read about x509-related serialization reminds me of that rant[1] about the PSD file format.
[1]: https://github.com/gco/xee/blob/master/XeePhotoshopLoader.m#L108 https://github.com/gco/xee/blob/master/XeePhotoshopLoader.m#...
- throwawaaarrgh 5y ago> and parsing of untrusted network input in memory unsafe languages Are these modern languages? I'm not aware of any modern ones that have a taint mode. Just Rust that has memory checking, Perl that has a simple taint mode, Ruby that has a more robust taint mode, and Jeeves which is like a general taint mode in a DSL in Python.
- dfox 5y agoThe issue with parsing ASN.1 is not inherent in the specification itself. The issue is about trying to produce DER/BER parser that is hardwired to parse particular instance of the syntax and directly fills some kind of C structs without the intermediate step of producing some kind of (DOM-like) tree of ASN.1 abstract objects. Something like this is usually done for two reasons: efficiency and the idea that such parser can be simpler than full BER parser (as it can ignore constructs that "cannot happen" in the particular syntax). Somewhat predictably, most ASN.1 software that uses this mental model of "ASN.1 is too complex, this is the easiest and fastest way to parse it" has something to do with cryptography, which makes the resulting issues even more critical. Valid criticism of ASN.1 would probably be that the abstract object model is too general on one hand and contains useless historical data types on the other (and the article is particular example of that). But that mostly is not related in any way to complexity and safety of the parsing or the currently popular meme of "unsafe" == bad.
- mordae 5y agoSince ASN.1 is not a proper TLV format (because you can change tag by using [tag] construct), you cannot fully decode it without up-to-date schema. It's much saner to parse it using a validating parser combinator than to go through an AST.
- pas 5y ago... could you explain this with a bit more detail, please? Asking for those very ubiquitous ASN.1 illiterate friends :)
- rkeene2 5y agoI can go over it -- I should note that I like ASN.1 (as described by X.690). As part of a project where I needed to parse X.509 certificates I wrote a simple ASN.1 -> X.509 parser which does the mapping in place. This can be found at [0]. So while it's possible to decode the structure of an ASN.1 object and many nested things, getting at a meaning requires understanding the schema of the objects being parsed since tags only describe the data type in a limited way. For example, to get the public key from an X.509 certificate you can easily do that -- but it will be an opaque ASN.1 structure unless you know if it's an RSA key or an ECDSA key, which is encoded as data in another ASN.1 OID somewhere, not as PART of the ASN.1 tag. So if you wanted to get the exponent for an X.509 certificate (like x509_to_exponent() does), then you need to know the schema for that type of public key -- here, it's specified in PKCS#1 (because only RSA is supported by this software), a completely unrelated standard. [0] https://cackey.rkeene.org/fossil/artifact/bc9c145e70285c54?ln https://cackey.rkeene.org/fossil/artifact/bc9c145e70285c54?l...
- pas 5y agoThat makes sense. After all if you have an arbitrary JSON (or XML) you don't know what is that, unless you have a schema, then you can check conformance, etc. And probably given a schema it's easy to give the user (developer) bound methods that reference some value in that "structured blob", and of course it's possible to reuse that method with other blobs. (While having some error handling of course.) But how come people have aversions with ASN1? Is it just stylistic as with XML? (And that it's used as the substrate for a bunch of old harebrained standards and protocols - all with artisanal shitghetti C codecs instead of the aforementioned robust parser + schema?)
- est31 5y ago> I wonder how long until we collectively decide to banish things like ASN.1 to the past Indeed, in the security community there is a trend to get rid of ASN.1. E.g. TLS uses a custom ad-hoc format: https://datatracker.ietf.org/doc/html/rfc5246#section-4 https://datatracker.ietf.org/doc/html/rfc5246#section-4 And this is used by e.g. certificate transparency: https://datatracker.ietf.org/doc/html/rfc6962#section-1.2 https://datatracker.ietf.org/doc/html/rfc6962#section-1.2 Maybe it's just a question of tooling, but personally I haven't found a binary format that is as nicely debugable as ASN.1. In many other instances I have to stare at hexdumps while for ASN.1, the lapo.it viewer exists. E.g. I still haven't been able to parse the extra_data of a certificate transparency log entry. In the case of ASN.1, you can dump it to lapo.it. How can you debug data in the ad hoc TLS format? There is literally no information in the binary format, you must know the schema. That being said, it's indeed more difficult to write parsers for ASN.1 formatted data without using ASN.1 libraries. The ad hoc TLS format definitely has an advantage here. But IMO ASN.1 has way too much of a bad name.
- tankenmate 5y agoHave you looked at XDR?