511 karma · joined Jun 20, 2015 (11y ago) · 248 submissions
https://neilmadden.blog/about
[ my public key: https://keybase.io/neilmadden; my proof: https://keybase.io/neilmadden/sigs/QfrQtB7H1Ni4rhaFpENFBtqqCd-VYDYXqYHKRfojHnk ]
comment 5y ago · link · parent
comment 5y ago · link · parent
You can also look at things like the Strobe framework, which builds essentially all of its symmetric crypto out of the SHA-3 core permutation: https://strobe.sourceforge.io/
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
[1]: https://datatracker.ietf.org/doc/html/rfc8446#section-5.4
comment 5y ago · link · parent
My point is that you can easily make this a complete non-issue by increasing the entropy of the token. 96-bit tokens are 16 characters in base64url - just 3 more characters than the 64-bit tokens used by Waterken, yet with a token space 4 billion times as large. By way of contrast, Google Docs URLs include a random string that is over 40 characters long.
comment 5y ago · link · parent
Your calculations assume that attackers are interested in brute forcing one particular token. But if your app issues a lot of tokens then it becomes easier for an attacker to find some valid token.
For example, if you issue a billion tokens and allow a thousand requests per second then I can find one of those tokens in about 100 days. Is that realistic? Maybe not, but it’s a lot lower than 250k years.
The second point is that I’ve several times in my life seen code that logs a hash of a security token to allow easy correlation of requests. Such a hashed log is then vulnerable to offline brute force attacks with very many more than a million guesses per second.
comment 5y ago · link · parent
comment 5y ago · link · parent
> isn’t it a problem if a module’s permissions may increase without explicit input from the module’s user (transitive or otherwise)?
Exactly right.
[1]: https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/
comment 5y ago · link · parent
You don't need to do this. There are a variety of ways to handle this, just as you would any other kind of dependency injection:
1. Design libraries to actually be modular so that dependencies (including capabilities) can be injected just where they are needed.
2. Pass in a factory object that lets the library construct sockets as and when it needs them. You can then enforce any arbitrary checks at the point of creating the socket. (This is much more flexible than a Java policy file).
3. Use a powerbox pattern [1] to allow the user to be directly asked each time the library attempts to open a socket. This is not always good UX, but sometimes it is the right solution.
> If the library develops a need for a new permission then the API must change and again, the whole thing has to be manually plumbed through.
Capturing permission requirements in the API is a good thing! With the stack walking/policy based approach I won't know the library needs a new permission until some library call suddenly fails at runtime.
comment 5y ago · link · parent
* The (now defunct) E programming language: http://erights.org and Joule: https://en.wikipedia.org/wiki/Joule_(programming_language) * Pony: https://www.ponylang.io * Monte: http://www.monte-language.org * The Midori project at Microsoft: http://joeduffyblog.com/2015/11/10/objects-as-secure-capabil...
It's actually not at all unworkable to use object-capability for large programs. In fact, one of the main benefits of ocaps is how well it aligns with well-established good software design principles such as dependency injection, avoiding singletons, avoiding global mutable state, and so on.
comment 5y ago · link · parent
The problem with Java’s stack walking is that it is too complex and too easy to find privileged code that can be coaxed into performing unintended operations. There are plenty of old write ups of Java sandbox bypass bugs due to this, eg http://benmmurphy.github.io/blog/2015/10/21/zdi-13-075-2013-...
comment 5y ago · link · parent
Indeed, if you look at the history of Java sandbox escapes they are largely confused deputy attacks: some privileged code source can be tricked into doing something it shouldn’t do.
comment 5y ago · link · parent
> FUNDAMENTALS-5: Minimise the number of permission checks Java is primarily an object-capability language. SecurityManager checks should be considered a last resort.
(Note: quite a lot of Java’s standard library is not designed along object-capability lines so you should take this advice with a pinch of salt).
[1]: https://www.oracle.com/java/technologies/javase/seccodeguide...
comment 5y ago · link · parent
comment 6y ago · link · parent
But grammar productions are also named and grammars are also designed to capture semantic notions. The syntax is after all intended to convey meaning.
comment 6y ago · link · parent
Do you have an example of this? It is not my experience of compiler intermediate representations or ASTs that they have this property.
> But since we all understand types and types can cover all the cases we've managed to find so far, I'd stick to types unless and until we can demonstrate a need for something else.
This doesn’t really argue with anything I wrote in the article. (Although I’d argue that nobody strictly “sticks to types” as their sole way to enforce correctness).
> trying to put types on those APIs is the easiest way to see that they're the wrong abstraction
I’m not sure I’d say it’s the easiest, but it certainly helps. I love Haskell as a language, primarily because it has a lovely set of well-designed abstractions. It’s clear the design of those abstractions were guided by types and benefit from that. Many of them remain good abstractions when translated to untyped languages.
comment 6y ago · link · parent
I know that it’s common to refer to type checking as “semantic analysis”, but the logician in me is not happy. There’s nothing inherently more “semantic” about types compared to grammars. As Benjamin Pierce says [1]:
> A type system is a syntactic method for enforcing levels of abstraction in programs.
(Emphasis mine).
> That said I agree that it is interesting to see what the 'parse, don't validate' approach to type checking would be, but I think it should still take place on the type level.
You can certainly write parsers at the type level, but that doesn’t change the fundamental fact that a type checker is a validator. To change a type checker into a parser it would have to output a representation which makes invalid states impossible to represent. From a programmer’s point of view (not the compiler writer), this means that the actual compiled object code would have to have this property. I can see a couple of possible ways you could do this:
- the compiled object code enforces invariants using dynamic checks provided by the runtime/processor - the type-checker outputs something like proof-carrying code [2] that can be rigorously checked prior to execution to ensure the illegal states removed by the type system cannot be recreated.
comment 6y ago · link · parent
1. The original "parse, don't validate" essay clearly describes why parsers are preferable to validators.
2. It uses a type system to make illegal states unrepresentable in a programming language - but a type system is a validator under its own terminology.
3. What would a parser-like approach to solving the problem look like?
I believe that actually adjusting the programming language grammar (and thus the actual parser) is clearly a parser approach to solving the problem. Abstraction is also, to me, a parser-like approach to solving the problem - it transforms code that allows illegal states into code that enforces particular invariants. I probably didn't make those connections explicit enough in the blog.
Perhaps the diversion into object-capabilities is a bit off the track, but I found it an interesting connection at least. (And frankly, I'm usually close to the sole audience of my blog so I better make it interesting for me!)
Edit: formatting
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent