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

Huge overhead for process communication, weird interface, weird semantics, etc.

comment 7y ago · link · parent

My opinion on static type systems is that, unless you're actually doing a more type driven development style and leveraging the type system, the single greatest benefit is IDEs will autocomplete for you, give you 'jump to' etc.

Python without type annotations can be painful in an IDE - it chokes a lot on those features.

Since I don't take a very type driven approach to Python (it would be too slow since I'd have to figure out 3rd party library types and shit like that) I just write annotations in places where I personally know the type. Mypy complains about this for various reasons - probably because my annotations are not technically correct, because I'm not a pro at generics in mypy and working out inheritance, as well as general mypy issues like poor support for class methods and that sort of thing.

But I ignore all of those errors because the IDE can still work things out.

comment 7y ago · link · parent

Why? Of course it's entirely possible to build programs of a larger size. I'm just saying that after a certain point you start hitting walls. There are tons of ways to hedge against this - leveraging mypy early on, spending more money (on eng, infra, ops, etc), architecting around the issues, diligence, etc.

It would be very silly for me to say that you can't build large systems in Python, I've worked on plenty that are much larger myself.

Saying a language is possibly the best for two important use cases (exploration, small programs) is quite a statement, in my opinion. I don't think I believe that there's a language that excels so well in, say, building web services.

comment 7y ago · link · parent

> Python explicitly does not agree with this...

OK, I'm willing to contend that that is the case. It doesn't have much to do with my overall issue with error handling.

> The same for a lot of your other complaints. It sounds like you are trying to write some other language in Python. Similarly if someone in a team using Java tried writing Python in Java they would complain a lot and end up with ugly hard to work with Java.

This is a very loose criticism of my post, I don't know how to respond to this. I've written Python for years, I think I gave it due credit for what it's good at.

I am not trying to write some other language with Python, I just think Python is not a very good language compared to others given a lot of fairly typical constraints.

comment 7y ago · link · parent

I'm not the person you're responding to but what they say resonates with me as a Python developer.

I believe Python is quite possibly the best language for a few things

* Exploratory programming - such as what data scientists do

* Writing programs that will never grow beyond 150LOC, or roughly what fits on a screen + one page down

When I have those two constraints met I am almost always choosing Python.

Here are some problems I face on codebases as they scale up:

* Python conventions lead to what I consider bad code. Devs will often choose things like 'patch' over dependency injection, and I have seen on multiple occasions projects derided for providing DI based interfaces - "oh, why would you write code that looks like Java? This is Python".

There's a lot of death by a thousand cuts. Keyword args in functions are abused a lot, because they're "easy", ability to patch at runtime means it's often "easy" to just write what looks like a simple interface, but it's then harder to test. Inheritance is "easy" and often leads to complex code where behaviors are very, very non-local.

Dynamic types mean that people are often a little too clever with their data. I've seen APIs that return effectively `Union[NoneType, Item, List[Item]]` for absolutely no semantic reason, without type annotations, meaning that if you assumed a list or none came back you were missing the single Item case. The implementation actually internally always got a list back from the underlying query but decided to special case the single item case... why? I see this sort of thing a bit, and other languages punish you for it (by forcing you to express the more complex type).

* I find myself more and more leveraging threads these days. I did this often with C++, and all the time in my Rust code. Python punishes you for threading. The GIL makes things feel atomic when they aren't, reduces you to concurrency, all while paying the cost of an OS thread. Threading primitives are also quite weak, imo, and multiprocessing is a dead end.

And, really, Python is anti-optimization, which is a good and bad thing, but it's a bit extreme.

* Implicit exceptions everywhere. I see 'raise Exception' defensively placed in every Python codebase because you never know when a piece of code will fail. I see a lot of reliance on 'retry decorators' that just catch everything because you never know if an error is transient or persistent.

The common "don't use exceptions for control flow" is broken right off the bat with StopIteration. I just think error handling in Python is god awful, really.

* Mypy is awesome, but feels like a bit of a hack. The type system is great, and in theory it would solve many problems, but coverage is quite awful in open source projects and the type errors I get are useless. I actually only use mypy to make my IDE behave, I don't run it myself, because my types are actually technically unsound and the errors are too painful to work with (and honestly the type system is quite complex and hard to work with, not to mention the bugs).

There are lots of other smaller issues, such as my distaste for pip, py2/3 breakage, lack of RAII, the insane reliance on C all over the place, I think syntax is bad in a lot of places (lambdas, whitespace in general), etc but these are probably my main sticking points with using the language for large projects.

Again, Python is actually my favorite language for specific tasks, but I really think it's best optimized for small codebases.

comment 7y ago · link · parent

Yes, and correct.

comment 7y ago · link · parent

Most recent (and the first public) Chrome ITW attack used memory corruption attack. One to exploit the renderer, another to exploit the underlying kernel to escape the sandbox.

I believe the same is true (roughly) with the Coinbase attack that went after Firefox.

In short, memory safety is not only responsible for the majority of reported vulns, but also the exploited ones, at least in the case of browsers.

> Heartbleed, Shellshock, Dirty COW etc. would all happen exactly the same way in different programming languages.

Heartbleed is impossible in a memory safe language, at the least. Same with cloudbleed for that matter.

DirtyCow and shellshock, sure.

It's a bit of a moot point though - human energy is finite, consider if we could spend energy on problems like DirtyCow and shellshock instead of memory safety issues that simply don't exist in many languages.

comment 7y ago · link · parent

> Security engineers in general, very much including Chrome Security Team, would like to advance the state of engineering to where memory safety issues are much more rare. Then, we could focus more attention on the application-semantic vulnerabilities. That would be a big improvement.

comment 7y ago · link · parent

I think this is just refinement types. You wouldn't so much ban the stdlib as need to wrap it.

comment 7y ago · link · parent

> We detected the attacker at this stage, based on a number of behaviors (e.g. Firefox shouldn’t spawn a shell).

They explicitly state it was one of the behaviors they detected as suspicious.

comment 7y ago · link · parent

Yeah, they could have moved processes before execing the shell. Detecting "Firefox + Shell" is quite easy and standard, even in existing SIEMs.

Detecting "arbitrary program + shell" is at least moderately more difficult.

It's the attacker's dilemma though. They only need to trip one alarm to trigger IR.

comment 7y ago · link · parent

Given how quickly coinbase managed to respond to an advanced attacker I think they know what they're doing.

Insider threat is also really difficult. Working from a point of "I don't trust my employees" is very painful for many reasons.

comment 7y ago · link · parent

That's not really something I expect from an attacker at all.

comment 7y ago · link · parent

The point of LOLBAS is not to identify exploitable programs but to identify useful programs for attackers. There is no issue of privilege here - if you are an attacker and you meet the privilege requirements, there you go, you can do these things.

The LOLBAS github has good definitions: https://github.com/api0cradle/LOLBAS

> LOLBAS candidates must be present on the system by default or introduced by application/software "installation" from a "reputable" vendor or open-source entity. Otherwise, LOLBAS determination is subject to scrutiny by the (security) community and agreed upon standards.

> Can be used as an attacker tool directly or can perform other actions than what it was intended to do (Ex: regsvr32 - execute code from SCT online)

Essentially, what programs on the operating system can an attacker abuse to do things that a defender will have a hard time monitoring for. The idea is that "bring your own binary" is dead (it isn't, but that's the idea) because it's too detectable/ preventable - software whitelisting, detecting unsigned apps, etc, make it hard. But if you can just leverage what's already on the system you can avoid detection more easily.

comment 7y ago · link · parent

"Living off the land" is a technique used by attackers to evade detection. It's easy to monitor for new binaries, or unsigned ones. It's harder to monitor for legitimate binaries that are generally used in your environmet - it requires extra context to determine "is this suspicious".

None of these programs are exploitable, they are useful to attackers. This is great for me, as someone whose job it is to protect a network - I can start thinking about how I can monitor these binaries.

comment 7y ago · link · parent

I doubt I could give you better advice than anyone else or the internet. Not trying to be dismissive, I just don't feel like I have a good handle on the question myself.

I can say that the trend at companies that pay well is that you will be able to pass an eng interview. More and more, it'll basically be "we expect you to be as good as an eng around your level, maybe one level less" and "we also expect you to be an expert at threat modeling", plus whatever is specific to your niche; for me it's detection and response, so I'm expected to understand operating system services, how attackers go about taking over a computer, the traces they leave behind, etc.

comment 7y ago · link · parent

You can go to levels.fyi and just add 5 to 10% to anything you see, and that's what I expect from the companies I apply to.

comment 7y ago · link · parent

I have an engineering background, which is quickly becoming a requirement for security roles. I do detection and response work.

comment 7y ago · link · parent

This is way off, the security community at large rejected the term cyber for years, but it was necessary to play ball with govt. That's it. The fact that vendors now leverage the word is irrelevant, that happened way later.

comment 7y ago · link · parent

Government wants to use cyber so we use cyber.

comment 7y ago · link · parent

I definitely feel like I have much more negotiating power than eng, as someone who used to be in an eng role and is now in security. There are more engineers and eng is a less niche skillset. There are very, very few people with my skillset. Hiring for my team takes months, minimum, with far far fewer candidates in our pipe.

I work at an SF company and routinely field offers from other companies that I can view on levels.fyi, and my colleagues in eng are open with me about their salaries so I have lots of datapoints to compare to.

To your other comment:

> I seriously question whether you understand how mediocre the mean security engineer actually is, even at top tier companies

This seems equally true for eng.

comment 7y ago · link · parent

There is no plugging all of the holes. Not in a general case. It's like the halting problem (it's technically equivalent) - maybe you can say for one program there are no holes, but not for arbitrary programs, for arbitrary definitions of holes.

This is rice's theorem.

More practically, you can simply assume that for an arbitrary program of 'reasonable size' with a moving codebase there are effectively infinite exploitable vulnerabilities.

comment 7y ago · link · parent

It's a term that's been adopted out of necessity.

comment 7y ago · link · parent

Look at security startups.

comment 7y ago · link · parent

Well the first Chrome RCE attack leveraged a Windows kernel exploit, so that seems like a reasonable one to point to.

comment 7y ago · link · parent

An effect system would solve this problem, as new system calls imply new effects, causing a breaking API change.
1
133134135
164