Better HN
topnewbestaskshowjobs
Log inSign up

staticassertion

13,486 karma · joined Jun 1, 2016 (10y ago) · 4,896 submissions

@insanitybit
Submissions

comment 7y ago · link · parent

I tried building something like this for rust, in order to execute closures as a separate process[0].

I could probably automate it for a struct with a macros so that the API was autosandboxed. Also, it was purely an experiment and is not particularly safe - secrets in the "broker" process would leak to the client, for example. I had plans to deal with at least some of these issues using a build.rs to generate a separate binary that could be exec'd but I stopped caring.

I wonder how this sandboxapi gets around that?

The reason I didn't bother was because I found that constructing the sandbox was the hard part, not executing the code in it - how do you detect what the code needs to do in the sandbox? You end up too tight or too loose.

Also, performance is miserable if you have to fork/exec every single time. So you may be tempted to cache the process across executions but that comes with its own pains. Again, curious how this is dealt with in sandboxapi.

Personally, I want to see sandboxing support at a language level. I imagine a language, perhaps like Pony, which has isolated units of execution that connect via some form of RPC/message passing. With a type system that "taints" types based on actions, basically a capability type that propagates upwards, you could generate seccomp filters for every unit of execution. Pony seems like it's actually not far from this, from what I could tell.

Sandboxing in a language like this is a matter of moving the execution unit out of process, which shouldn't be that hard.

[0] https://github.com/insanitybit/sandbox

comment 7y ago · link · parent

> So the only message passing between your rust actors is via SQS or such?

It's S3 -> SNS -> SQS -> Lambda

This gives me:

* Persistent events on s3, for replayability

* Multiconsumer for SNS

* Dead letters, retries, etc via SQS

Maybe from a latency perspective this is slow, but my system can tolerate latency at the level of minutes, so I'm really doubtful that my messaging system will matter.

Most time is spent downloading payloads in S3 as far as I know. I batch up and compress proto events to optimize this.

I haven't tried scaling out my system but I'm confident that message passing is the least of my concerns.

comment 7y ago · link · parent

I'm not advocating for Erlang over type safety. I personally prefer a type based approach. They are also not incompatible.

That said,

> I have yet to see some convincing proof of that

There is no proof, but I can point you to research.

pdf warnings: https://jimgray.azurewebsites.net/papers/tandemtr85.7_whydoc...

This paper is fundamental to reliability, and describes two primitives for building reliable systems - transactions, and the "persistent process" (spoilers: it's an actor).

And here's Joe Armstrong's thesis. The first 3 chapters are quite relevant and will point you to further research

http://erlang.org/download/armstrong_thesis_2003.pdf

> besides that Ericsson router from 20 years ago that ended up being rewritten in C++.

This is missing some important information. Erlang is still used at the control plane/ orchestration layer, for exactly the reasons I've described.

> This still doesn't prove that there are no languages that can do a better job at it than Erlang.

Didn't say otherwise.

> 99.99% of extremely reliable software today runs on non Erlang: C, C++, Java, you name it.

Sure, but who cares about Erlang? The real money's in isolated persistent processes aka actors, and I bet most reliable software is built on those, whether language provided or not. See AWS's cell based architecture, which is just the actor model with discipline attached. Or all of microservice architecture.

> Finally, in my experience, writing supervisors in Erlang is just as painful, and if not harder, than writing resilient code based on exceptions in Java or C++.

That's ok.

comment 7y ago · link · parent

They're no longer manufactured, and therefor the numbers are only decreasing. A quick look at amazon prices one at ~100 dollars. What do you think that'll be in a decade?

Certainly some games are already quite pricey as there are fewer and fewer copies out there (check out prices for SSBM).

comment 7y ago · link · parent

> Types aren't just for catching type errors, they're also a way of defining and enforcing at least parts of the programming contract.

I don't disagree. To be clear, I'm a type safety zealot.

> You will eventually be paying for that when the first major refactor comes - if it comes, that is.

This is fine but not relevant. Erlang, for example, just assumes you'll fuck up the refactor. Actors are isolated interfaces and you can not share state - so a failure in one actor can not impact other actors directly.

It's fine to say that static types are better but if you read about Erlang you may find the approach very compelling - Erlang's managed to provide the basis for extremely reliable systems, without types.

And as I said, it is not either or. You can build power supervisory structures and statically type your code if you like, but no languages really do it, so you have to reach outside of the language (like using a distributed queue/ microservice approach).

comment 7y ago · link · parent

We also have posts about hackers and all sorts of shit. It's here because it's technically interesting.

Projects like this are also critical - tons of media running on proprietary hardware/software will be lost without projects like this. Think about DOSBox, or even just Flashplayer games, or how rare an n64 is. All of the art produced on these platforms will be lost unless we build software to run it.

Emulators are also, generally, ~5-10 years behind the consoles. At that point the consoles themselves are likely deprecated in favor of the next platform. PS3 has been out for 13 years. Do you really believe this code will negatively impact sales of games, when it's usable nearly 2 decades after release?

*edit

And a side note - I believe PCSX2 was the first program I ever compiled, as a teenager. It was at least some part of what interested me in computers - I wanted to know why some games were slow or fast, or what role the GPU played. Emulators are some of the coolest projects out there, I think, and posts about their implementation seem very fitting for HN.

comment 7y ago · link · parent

There's definitely still a cost to static types.

Types can be thought of as a way to defensively program - encode what you can to avoid runtime errors. At minimum this means you have to think about your constraints - we may both agree that that's a fine tradeoff, but it's a tradeoff nonetheless.

Erlang, an actor based system, does not do this. Instead, it assumes that even if you added types youd run into failures and any reliable system should spend its efforts not trying to avoid that but to deal with it.

Erlang allows you to instead encode failure modes in an extremely resilient way (supervisory trees) and to trivially move code across networks to avoid hardware failures.

Languages like Python, in my opinion, are the worst of both worlds. Python encourages lots of shared mutable state but, until recently, offered very little static analysis. Time was instead spent on testing code - something that I do not believe it does any better than Erlang or a statically typed language.

To me, the answer is sort of... why not both? We can use actors and supervisory trees and static types. As an example, I write Rust services that execute on AWS lambda in response to queue events. I get state isolation and all of the good bits of the actor model, and static types.

Pony is a more fine grained solution, offering static types and in-process actors.

comment 7y ago · link · parent

I actually wanted to post the same thing.

Alan Kay's view of OOP is mostly just the actor model. But the actor model, like OOP, does not tell us how to actually build programs. "When do I use an object?" is a question OOP does not answer, "When do I use an actor?" is similarly not answered by the actor model.

Service Oriented Architecture is also effectively the actor model, but with a focus on the persistent process abstraction.

What Microservices does is take the actor model and say:

* Here's how you figure out where the actor abstractions should go, how large they should be, and patterns for interaction

Where microservices soooort of diverges is in its lack of discouragement of synchronous communication. But if you build your microservices using queues, I think you get the right sized actors with all of those benefits, without going down a rabbit hole of trying to structure every single bit of logic as an actor.

AWS's "Cell Based Architecture" is also just actors, but with its own set of patterns for how large to build them.

comment 7y ago · link · parent

Sure but one room is probably hosting > 2 hours of meetings in a day.

Doors opening probably helps though?

comment 7y ago · link · parent

Not sure - never to my knowledge. I'm still allowed to be worried. This issue is also not really apple specific - Android has health monitoring features, and I trust OEMs a lot less.

I'm not stating that this has happened, but yeah, I worry.

comment 7y ago · link · parent

I'm more concerned with the data being sold/ leaked and it impacting insurance premiums.

comment 7y ago · link · parent

That lacks the context of their age.

Go is 10 years old, scala is 16 - 60% older, and it was built on top of the JVM, which is much older than that.

I feel like that's worth mentioning, because it seems like Go has more momentum - maybe there's data that shows otherwise though, like trends in Redmonk over time. I had a quick look and didn't see an easy way to get that. I'd be happy to be proven wrong, it's just the impression I get.

comment 7y ago · link · parent

It's interesting that you chose Elixir, Groovy, Scala, and Clojure as examplars - they seem like failures from an adoption standpoint.

Go, your exception, is by far the most successful of the languages listed.

comment 7y ago · link · parent

FWIW, Scott Piper, who builds CloudMapper, also consults.

Glad I could help.

comment 7y ago · link · parent

Sorry, I just misread your post as being more of an attack. As I had said, I dislike the constant "hype means something is bad" posts that I've been seeing for years - I think it's really unfortunate.

comment 7y ago · link · parent

edit: See below

comment 7y ago · link · parent

I think there's a very big difference between the runtime being implemented in C and the libraries being implemented in C.

comment 7y ago · link · parent

I think what you're getting at is Grapl's identification process. It's timestamp based, primarily, at the moment, yes.

A bit of the algorithm is described here: https://insanitybit.github.io/2019/03/09/grapl

More specifically Grapl defines a type of identity called a Session - this is an ID that is valid for a time, such as a PID on every major OS.

Sessions are tracked or otherwise guessed based on logs, such as process creation or termination logs. Because Grapl assumes that logs will be dropped or come out of order/ extremely delayed it makes the effort to "guess" at identities. It's been quite accurate in my experience but the algorithm has many areas for improvement - it's a bit naive right now.

Happy to answer more questions about it though.

Based on what you seem to be interested I'd like to recommend CloudMapper by Scott Piper.

https://github.com/duo-labs/cloudmapper

comment 7y ago · link · parent

I've built my personal side project as microservices. I started with an initial POC in Python and then I had a clear vision for what services to build.

https://github.com/insanitybit/grapl

> I’d have the readme on Github, and often in an hour or maybe a few I’d be up and running when I started on a new project.

I can deploy all of my services with one command. It's trivial - and I can often just deploy the small bit that I want to.

I don't use K8s or anything like that. Just AWS Lambdas and SQS based event triggers.

One thing I found was that by defining what a "service" was upfront, I made life a lot easier. I don't have snowflakes - everything uses the same service abstraction, with only one or two small caveats.

I don't imagine a Junior developer would have a hard time with this - I'd just show them the service abstraction (it exists in code using AWS-CDK)[0].

> This in contrast to my standard consolidated log, and lets not forget my interactive terminal/debugger for when I wanted to go step by step through the process.

It's true, distributed logging is inherently more complex. I haven't run into major issues with this myself. Correlation IDs go a really long way.

Due to serverless I can't just drop into a debugger though - that's annoying if you need to. But also, I've never needed to.

> But now to really test my service I have to bring up a complete working version of my application.

I have never seen this as necessary. You just mock out service dependencies like you would a DB or anything else. I don't see this as a meaningful regression tbh.

> That is probably a bit too much effort so we’re just going to test each piece in isolation, I’m sure our specs were good enough that APIs are clean and service failure is isolated and won’t impact others.

Honestly, enforcing failure isolation is trivial. Avoid synchronous communication like the plague. My services all communicate via async events - if a service fails the events just queue up. The interface is just a protobuf defined dataformat (which is, incidentally, one of the only pieces of shared code across the services).

Honestly, I didn't find the road to microservices particularly bumpy. I had to invest early on in ensuring I had deployment scripts and the ability to run local tests. That was about it.

I'm quite glad I started with microservices. I've been able to think about services in isolation, without ever worrying about accidental coupling or accidentally having shared state. Failure isolation and scale isolation are not small things that I'd be happy to throw away.

My project is very exploratory - things have evolved over time. Having boundaries has allowed me to isolate complexity and it's been extremely easy to rewrite small services as my requirements and vision change. I don't think this would have been easy in a monolith at all.

I think I'm likely going to combine two my microservices - I split up two areas early on, only to realize later that they're not truly isolated components. Merging microservices seems radically simpler than splitting them, so I'm unconcerned about this - I can put it off for a very long time and I still suspect it will be easy to merge. I intend to perform a rewrite of one of them before the merge anyways.

I've suffered quite a lot from distributed monolith setups. I'm not likely to jump into one again if I can help it.

[0] https://github.com/insanitybit/grapl/blob/master/grapl-cdk/i...

comment 7y ago · link · parent

> Firstly, the program spends most of its time in the heavily-optimized str.find function, which is implemented in C.

I'm not going to outright call this "cheating", but most of the time, virtually unconditionally, when Python is fast it's because it isn't Python, it's C.

It definitely feels worth noting that Python is radically slower than other languages, and the main "tool" it provides for improving performance is to rely on another language entirely.

comment 7y ago · link · parent

Oh yeah - if it kept coming back that's pretty annoying.

comment 7y ago · link · parent

Can you uninstall Candy Crush? It doesn't seem that egregious if so.

It is / was an extremely popular game, they probably figured:

* We can make some money

* Users love this garbage anyways

I haven't been a Windows user for years, but Windows 10 looks fairly impressive - especially from a security standpoint.

comment 7y ago · link · parent

You're attempting to derive meaning from my post, which in your mind is that browsers should not use C++, where there is no such meaning.

That you have failed to do so is not my issue. Don't blame me for having an upvoted post.

comment 7y ago · link · parent

You've missed my point entirely. This is not a plea to Chrome to rewrite their browser. My post has nothing to do with browsers.

My claim is that Chrome is an interesting case study in the most hardened user-facing C++ codebase in the world being hacked because of memory unsafety.

I also think that the strawman argument you've made is extremely weak for other reasons. This whole "insecure by design" thing is nonsense - everyone stating this seems to not understand that multitenant systems have existed for ages, under far more difficult constraints. An example - AWS Lambdas colocate your code with other companies' on the same hardware - if this were such an impossible task, that wouldn't be possible.

But again, my argument is not about browsers, or even much about languages, and is merely me pointing out an interesting case where memory unsafety was the root cause of an attack, despite great efforts.

comment 7y ago · link · parent

Naturally, but I think maybe you missed my point.

I listed a subset of the things Chrome does to help mitigate the fact that C++ bugs will make it out. It's because they don't trust C++ that this is the case.

What is interesting is that, in the case of the first itw exploit, the root case appears to be memory safety. That despite the many millions invested, memory safety was still what an attacker went after and managed to leverage into an exploit against users.

That's all.

comment 7y ago · link · parent

Yeah, totally. I'm not saying they shouldn't use C++ (though I think they could probably save a ton of money if they did). I'm saying that they spend a lot of money on security, they do an incredible job, and stuff like this can still slip through, which I find really interesting.

comment 7y ago · link · parent

> there's zero reason to blame C++

Seems like UAF in C++? So, yes, I feel comfortable blaming C++.

Anyways, I didn't mention memory safe languages in my post, and I'm not even suggesting that Google did anything wrong, or should change their posture in any way. They've been extremely successful.

comment 7y ago · link · parent

> This is a bit of a simplistic view tbh.

It's a very literal one.

I think I've been very open about what an accomplishment they've made, and how proud they should be to have kept Chrome users safe for all of these years.

It is exactly because their efforts to secure Chrome are so impressive that I think this event is interesting.

None of what I've said is about Rust or even a suggestion that they shouldn't keep doing what their doing. One ITW exploit in a lifetime of a product is a great track record.

It is merely interesting to observe when herculean efforts fall down.

comment 7y ago · link · parent

You're right that it's a real footgun, the major issues that I'm aware of are in the native serializer, but yeah even the big libraries like Jackson have had issues.

I don't consider those on the same level as memory unsafety, personally, but it's not really a meaningful comparison because I'm not going to dig around for numbers and mitigation techniques.

comment 7y ago · link · parent

I'm not really interested in having a language shootout but I will say that I think you may be misunderstanding Java's history of serialization vulnerabilities.
1
139140141
164