Better HN
topnewbestaskshowjobs
Log inSign up

nmadden

511 karma · joined Jun 20, 2015 (11y ago) · 248 submissions

Author API Security in Action - https://www.manning.com/books/api-security-in-action

https://neilmadden.blog/about

[ my public key: https://keybase.io/neilmadden; my proof: https://keybase.io/neilmadden/sigs/QfrQtB7H1Ni4rhaFpENFBtqqCd-VYDYXqYHKRfojHnk ]

Submissions

comment 6y ago · link · parent

This is not necessarily true - deterministic EC signatures are now recommended, eg EdDSA or [1] for ECDSA. (To prevent some side-channel attacks you might want to reintroduce some randomness).

On the other hand, it’s now recommended to use PSS padding with RSA, which requires a random value for each signature.

[1]: https://tools.ietf.org/html/rfc6979

comment 6y ago · link · parent

We’re still waiting to find one of those proper implementations 20 years later.

comment 6y ago · link · parent

Switch to other proven and mature algorithms eg libsodium, Tink, etc. RSA has not been the only game in town for a long time.

comment 6y ago · link · parent

See for example Dan Boneh’s “20 years of attacks on the RSA cryptosystem” [1]. Itself now written 20 years ago and the attacks keep coming.

[1]: http://www.ams.org/notices/199902/boneh.pdf

comment 6y ago · link · parent

The point of the article is that mature and well-vetted libraries have repeatedly been shown to have vulnerabilities in their RSA implementations. See [1] for just one recent example, but there have been many.

[1]: https://www.cryptologie.net/article/461/the-9-lives-of-bleic...

comment 6y ago · link · parent

One day I’d love to find a reasonably priced copy of LiSP. It’s the most elusive widely-recommended book I’ve ever come across.

comment 6y ago · link · parent

I’m not sure what the state of the art is, but certainly Prolog has been used for these kinds of things. Specialised dialects like ECLiPSe [1] have lots of options for solving constraint optimisation problems.

[1]: http://eclipseclp.org/

comment 6y ago · link · parent

It’s only 3rd-party cookies, right?

comment 6y ago · link · parent

Well like any large codebase there will be things that need improving. The handful of places where we have similar issues are relatively unlikely to cause a real problem in the near future.

comment 6y ago · link · parent

Funnily enough, I actually suggested we adopt something like GREASE for OAuth parameters: https://mailarchive.ietf.org/arch/msg/oauth/Rqxs-QDqqdQkt36S...

There wasn’t a lot of support.

comment 6y ago · link · parent

As an example, rejecting unrecognised query parameters can cause ossification of web protocols. For example, I do a lot of work with OAuth and it is accepted security best practice now to use PKCE [1] on all authorisation requests [2]. However, despite the OAuth spec saying that authorisation servers MUST ignore unrecognised parameters [3], there are many major services that fail if you add a PKCE code_challenge parameter. This means generic client libraries either don't implement PKCE or have to maintain a list of sites that don't work (which gets stale over time) or have some risky downgrade logic.

So there is a tradeoff between strict validation and allowing future expansion and upgrades. By all means strictly validate the parameters you need, but maybe don't reject parameters you don't recognise.

[1]: https://oauth.net/2/pkce/ [2]: https://tools.ietf.org/html/draft-ietf-oauth-security-topics... [3]: https://tools.ietf.org/html/rfc6749#page-19

comment 6y ago · link · parent

That’s an ok(ish) definition of indistinguishability for a block cipher, but not for a mode of operation like ECB.

comment 6y ago · link · parent

These kinds of patterns are present in input data quite often - eg fixed headers, markup etc.

As usual, there’s even an xkcd on it: https://xkcd.com/1286/

comment 6y ago · link · parent

Which is the classic illustration that ECB is _not_ indistinguishable from random, even to a casual observer.

comment 6y ago · link · parent

The Tower Number Field Sieve is only applicable to pairing-based ECC though, right? It doesn't impact the security of the curves used in most mainstream crypto (Curve25519, NIST P-256 etc).

comment 6y ago · link · parent

Tcl has had sandboxed interpreters with resource limits for a long time [1]. You can even remove built-in commands (for/while etc) if you want to. You can limit the language to a purely declarative subset and selectively expose commands and resources as you wish.

[1]: https://www.tcl.tk/man/tcl8.5/TclCmd/interp.htm#M46

comment 6y ago · link · parent

https://www.logicmatters.net/tyl/

comment 6y ago · link · parent

Firstly, setting the domain attribute on a cookie explicitly allows sub-domains. You want to leave that off to enable host-only cookies. But secondly, as I just said the host/domain on the cookie does nothing at all to prevent cross-origin requests to that domain, which is the relevant concern for CSRF. Setting the domain/host is completely irrelevant to this attack.

Yes, adding to PSL is not at all scalable and will likely cause you a world of pain down the road. It was not intended as a serious suggestion. Use proper CSRF defences.

comment 6y ago · link · parent

That doesn't impact CSRF at all. If I send a request from a page on foo.example.com to api.example.com your browser will send those cookies no matter how tightly scoped they are because the destination of the request matches the cookie. It will send those cookies whether you use host cookies, add a __Host_ prefix, set SameSite=strict, Secure, HttpOnly, etc, etc, etc.

If you want to protect against these attacks with basic cookie attributes you can use SameSite and register your site (and any intermediate sub-domains) on the public suffix list to effectively shun your subdomains as being completely separate sites.

comment 6y ago · link · parent

Subdomain hijacking is not rare for the simple reason that websites are built by marketing departments. E.g., here’s Hanno Böck tweeting about a subdomain takeover he found at Kaspersky just recently: https://twitter.com/hanno/status/1257958739132514304 There’s a whole cottage industry of people finding these vulnerabilities on a very regular basis: https://www.hackerone.com/blog/Guide-Subdomain-Takeovers

comment 6y ago · link · parent

This isn't true. Although SameSite is a good defence in depth, it provides no protection against CSRF from sub-domains (subdomain hijacking is fairly common), or in older browsers. It also is incompatible with some site features - e.g. OIDC form_post response mode, SAML SLO with HTTP POST binding, etc.

comment 6y ago · link · parent

Well this is trivially true: here's my domain specific language "main". It has a single keyword "main" that when executed runs the main method of the 100 million line codebase (which is the language runtime).

comment 6y ago · link · parent

Right, and it’s not just Safari. This is the current complexity of User-Agent sniffing that the SameSite change requires if you need to disable it:

https://www.chromium.org/updates/same-site/incompatible-clie...

comment 6y ago · link · parent

I updated the blog post, I had misunderstood that part of the age spec.

comment 6y ago · link · parent

Yes, but no such tool exists (yet) as far as I’m aware. You also need to tie the chunks together so that they cannot be rearranged, duplicated, or deleted.

You also need to be careful about what you think this tells you. For example, suppose you ran a competition where the winner is the first person to upload an encrypted+signed correct answer to a shared folder. An attacker can wait for somebody to upload the winning answer and then simply strip the real winner’s signature off and sign the encrypted blob (which they can’t decrypt) with their own private key - hurray, the attacker has now won the prize!

If you reverse the order of signing and encryption you can run into bugs like [1].

You can securely combine public key encryption and signatures by including extra metadata fields inside each layer. Or you can use a function that provides public key authenticated encryption like NaCl’s crypto_box or the mode I’ve proposed for JOSE [2].

[1]: https://groups.google.com/forum/m/#!msg/sci.crypt/73yb5a9pz2... [2]: https://tools.ietf.org/html/draft-madden-jose-ecdh-1pu-02

Edit: clarify ambiguous use of “their”

comment 6y ago · link · parent

If this is all you need use age with a password/passphrase (scrypt). It does exactly what you want.

comment 6y ago · link · parent

Yes, I raised an issue on github. But I think there are general points raised that are more widely applicable than just to age.

comment 6y ago · link · parent

I wrote up some more detailed notes here: https://neilmadden.blog/2019/12/30/a-few-comments-on-age/

comment 6y ago · link · parent

An example of why I think this is important. Adam Langley’s post that is linked from the spec [1] talks about cases where people want to do things like:

    decrypt file | tar xz
Elsewhere in these comments somebody also mentioned the case of

    decrypt file | sh
Presumably the whole point of implementing the STREAM online AEAD mode is to support these kinds of cases; only releasing chunks of plaintext after verification.

But these use-cases are only secure in age when using the scrypt decryption option or if you have first verified a signature over the entire age-encrypted archive (killing the streaming use-case). The reason is that the X25519 age variant provides no sender authentication at all, and so an attacker doesn’t need to tamper with the archive: they can just generate their own ephemeral key pair and replace the entire thing with data of their choosing. Age has no way of detecting such an attack.

You absolutely need origin/sender authentication built directly into the tool to handle these cases securely.

[1]: https://www.imperialviolet.org/2014/06/27/streamingencryptio...

comment 6y ago · link · parent

Is there a detailed description of the security goals and crypto rationale anywhere?

For example, it seems that if you use scrypt then you get fully authenticated encryption: the message must have come from somebody who knows the password (either a trusted user or you chose a weak password). But if you use X25519 then the scheme used is ECIES, so no sender authentication, only IND-CCA security.

The format document says that if you want “signing“ then use minisign/signify, but I suspect most people want origin authentication. We know that it is actually quite hard to obtain public key authenticated encryption [1] from generic composition of signatures and encryption, with many subtle details. It would be better if age supported this directly for X25519 as it does for scrypt. Unfortunately, you can’t simply use a static key pair to achieve this (as in nacl’s box) as age uses a zero nonce to encrypt the file key with chacha20-poly1305 so reusing a static key will result in nonce reuse. (This seems a bit fragile).

[1]: https://eprint.iacr.org/2001/079

1
56789