311 points · by zdw · 7y ago · 124 comments
http://lucacardelli.name/Papers/TypefulProg.pdf is now next on my list when I finish reading A Philosophy of Software Design (which is brilliant if you haven't seen it).
Actually with .NET Native, the GC improvements in .NET 4.6 (TryStartNoGCRegion() and other companion methods), and the C# 7.x improvements taken from Midori, it is quite close.
I am up for you elaborating a bit on the second sentence since it sounds interesting. Not doing .NET, I don't know what any of those are except the middle one which sounds like SYSTEM/UNSAFE sections.
Same with Ada I just have no use case for it alas.
At least C# (amongst others) borrowed a fair amount of the concepts.
That said, Go follows the Wirth tradition most among the popular languages. People are learning it fast, coding stuff fast, and the apps are safer. Definitely a success. :)
If there is something positive walled gardens can bring to the table, it would be more of ecosystems where entire classes of exploits are completely mitigated. I think it's something that users and devs should be asking for. (We did it with USB plugs you don't have to flip over.)
He hints it's barely possible to write correct C. He doesnt mention how safety-critical sector, esp regulated, cranks out reliable C on a regular basis. They use C subsets with careful coding, reviews, and every automated tool they can. Static analyzers, automated testing, you name it. There's also analyzers that, when they work, can prove absence of entire classes of errors. RV-Match, Astree Analyzer (used by Airbus), and Frama-C are examples. CompCert eliminates compiler errors afterward. Most security-critical development doesnt use tools like these even when companies can afford them. It's apathy, not technological capability.
Now, C++ is special given it was designed to reduce risks of using C. Yet, almost all the verification tooling was for C and Java. C++ is just so complicated that it's hard to statically analyze or even build tools for. That means a C program done like above might have fewer errors than a C++ program. For that reason, I recommend avoiding C++ in favor of either C or safe systems languages compiling to C to take advantage of its verification tooling. They're getting hit with these vulnerabilities because they using a harder-to-analyze language possibly with coding strategy that adds difficulty. See Cleanroom Software Engineering or Praxis's Correct-by-Construction for examples of low-defect, development strategy.
I think C++ still has good strong merit but it definitely needs some critical thinking about where it's used. Other languages are likely better candidates for most things.
I'm looking at job ads periodically and Rust is almost not at all present. I've talked to someone from the Rust community and they told me that "many" companies are using Rust, but not advertising it and not hiring for it on public channels.
Whatever the reason, the Rust skills market seems to be non-existent, which is a bad position to be in when considering whether to start a project in Rust. Project = commercial product that makes money, not OSS or start-up dreams.
I prefer other higher-level languages to Rust; I'd rather just work with garbage collection than wrangle the Rust borrow-checker. But if you need to write software that can't abide GC, Rust is basically the only memory-safe game in town.
It is true that there’s no nearly as many as Java or C++, but that’s pretty normal given relative ages.
It is not however impossible to find jobs in Rust at the moment. I think January's Who is Hiring post had 5 rust job listings. Rust is still not used in a wide range of industries, but you can find a number of opportunities in crypto, fintech, security, and even a few big data shops.
And yes, there's even more jobs that aren't always out there on public channels. Good reason to attend your local rust meetup.
How do you know whether the commercial product is going to make money when you're still considering what programming language to write it in? Until it's built and launched, it's just a "commercial product dream", similar to a "start-up dream".
Right now projects have the option of building with the santizers (particularly the address sanitizer) enabled, right? The executable would be slower and less memory efficient, but it would eliminate most of the critical CVEs that exploit invalid memory access. Is there a reason Google couldn't provide alternative builds of Chrome with the santizers enabled?
As for the foreseeable future, you can come up with arguments (convincing or otherwise) that C++ will be effectively memory (and data race) safe in the foreseeable future. At some point, presumably the core guidelines lifetime checker will enforce memory safety. To what degree it will in practice is a matter of speculation, but in theory it could be as effective as the Rust compiler.
Just as an observation, if you peruse the chromium source code, from a modern C++ perspective, there seems to me to be an alarming prevalence of raw pointers. (Probably understandable as chromium's been around for a while.) C++ is now a very powerful language, and if (memory) safety is a priority it is already practical (and performant[1]) to avoid the use of notoriously unsafe elements like raw pointers and unchecked buffers in favor of safer alternatives. (It is similarly practical to avoid data race prone elements[2].)
[1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus-BenchmarksG...
[2] https://github.com/duneroadrunner/SaferCPlusPlus#multithread...
This article is arguing that for safety/security, you shouldn't use it. For the majority of projects that are more complex than Hello World, you'll be venturing out of "relatively safe".
Whereas in some systems languages with modules, if you make use of unsafe code blocks or pseudo-module, the module gets tainted and you can even block its use.
Using -Weverything other than for a one-off, manual build, is a sure fire way to result in one or several of 1) hacky code that works around some compiler author's style preferences, 2) less safe code because of the workaround hacks, or 3) coworkers quickly learning to ignore or disable (e.g. using inline #pragma's) diagnostics.
For both GCC and clang, -Wall comes close to the line of rejecting objectively correct and good code, but doesn't quite cross the line. -Wextra crosses that line (expect it to reject some correct and good code) but the pros often outweigh the cons. -Weverything blows past the line and wraps around the earth several times.
We'll see plenty of other NPM disasters this year, and as always, nothing will change because security is an afterthought not a core mission principle.
If it was, NPM wouldn't exist in its current form. It's confusing, adding extra security wouldn't even be that difficult or time consuming, they just don't.
I wish it were possible to take over a project with individuals who actually care. The people in charge of NPM are incompetent at running a secure, large scale distribution system, why they're still allowed to be a part of it is beyond me...
If security isn't your top goal you don't belong in charge of a very important, widely used ecosystem which many rely on.
As I see it people want to use the code third parties control but without trusting them somehow. Package management alone can only go so far. Code just has too much privileges in a language like javascript and no matter what you do something coming from third parties can pwn you or at least facilitate that.
There needs to be a language where code doesn't have so much privileges. Imagine if the language only allowed to import functions that either have no side effects or each side effect required explicit security token, say for reading some file or connecting to some remote host. Instead of passing strings around and let any function have unlimited privileges to read any file, the code would pass security tokens around that let functions only read specified files. Think language level capability-based security. I can't think of anything else that can help with random third party code.
https://blog.npmjs.org/post/166039777883/protect-your-npm-ac...
Can't say I'm aware of any other package manager even discussing these issues.
On the other hand, if your crates.io account is linked to a GitHub account, you could have 2FA via GitHub. So I'm not entirely sure whether "cargo supports 2FA" would count as true or false at the moment.
What are some alternatives that are not a synonym for engagement?
I can be satisfied with products that I don't use at every moment of every day.
I am usually more satisfied with my life when I am not being gamed to be addicted to something such as a "free" product.
If you're satisfied with my product, but you only buy it once a year, that's bad for me. If you're not very satisfied with my product, but you buy it 30 times a year, that's better.
I'd rather have 30 sales than 1 sale, even if you badmouth my product and lose me 15 more sales down the line.
TBH I may not give a crap how "happy" you are if you're still engaging.
Satisfaction is trailing, engagement is leading.
Did you try asking me?
> and what I'd have to change to do that?
Again, did you try asking me?
> If you're satisfied with my product, but you only buy it once a year, that's bad for me. If you're not very satisfied with my product, but you buy it 30 times a year, that's better.
If I'm satisfied with your product what makes you think I'd be more satisfied with it if I had to buy it multiple times per year?
> I'd rather have 30 sales than 1 sale, even if you badmouth my product and lose me 15 more sales down the line.
You assume every sale is the same price. If you sell your product to 30 people, are those 30 people generating the same amount of revenue as the 15 people could have if they were more satisfied with your product?
> TBH I may not give a crap how "happy" you are if you're still engaging.
That is, in a nutshell, exactly why I'm not satisfied with many online products and have actively disengaged from them. Your line of thinking leads down a road where the end user is nothing except a source of income to you. You've completely forgotten that you're supposed to provide a service for humans. It shows a complete lack of respect of users' intent and instead you wish to push users to generate more money for you potentially at the cost of the users themselves.
"I may not give a crap how 'happy' you are if you're still engaging" - you've really put it succinctly. That's the mentality of a drug pusher.
Besides, the only reason engagement became a thing is because the way people are paid is based on ad revenue instead of actual payment by the person using the product. Satisfaction is king when the user and the customer are the same person. Just ask any insurance company (for example).
Your goal should be for something more specific, and ideally at least a tad more concrete. Things like "product satisfaction," "positive impression of brand," and "purchase intent" could all be synonyms for "engagement" but they are not synonyms with each other because they are all more specific and narrowly-defined. And furthermore, they're better guidelines because particular features or activities could be well-suited for one and not another, so optimizing towards one of those actually provides some focus.
Now that I've established how much I love Linux and the FOSS movement (I'll still defend it over proprietary works) , I'm also a realist. Realist because when you do a lot of security dev then reality on Linux looks different today. Sticking for sake of discussions with monolith kind of kernels (comparing oranges with oranges) I absolutely hate the security design choices of modern Linux. Linux could do a lot better in this regard and Torvalds doesn't do the industry a favor when he calls security experts a bunch of masturbating monkeys. I can see where he comes from but the attack surface on any type of Linux (whether embedded or not), I'd go as far to call it total trash when compared to its BSD cousins. A lot of this isn't just Linux's fault considering how big the system is today. To realistically secure a Linux system is almost impossible (within budget+time that is) when compared to BSD.
The only reason why I still put up with Linus is because of FOSS. But if it were purely for security (on a desktop system) I'd have to say Linux is really poor.
It hasn't always been that way. My theory (really just theory) is that while Microsoft got hammered for decades for having shit security (remember trustworthycomputing.com ??). And I think the message slowly but gradually sank in at Redmond. Microsoft (and I still get hick-ups when saying it) somehow got their act together. I believe all that pressure amounted to something in the end while the Linux community missed the train. Not to say that there aren't brilliant ideas coming out of that community but there is very little pressure to provide integrated security that actually protects the user in a coherent way. You get lots of little pockets of good and bad (as is the nature of FOSS) and integrating it isn't even done well by the major distributions.
Again not saying Linux can't be secure but to make it good depends a lot on who integrates and sets up the system. And for the end-user who only has a semi-technical background (never heard of threat-modeling or grsec ... for them it's a dumpster fire).
I'm not comparing Linux to Apple here because Apple security is brilliant and thought all the way through to the UI/UE level. Linux in that regard doesn't even stand a chance. @thegrugq has a pretty good guide for OpSec/ComSec which is still relevant to this very day that spells out the tough reality (which a Linux fan like myself doesn't always appreciate hearing): https://news.ycombinator.com/item?id=8950875
I'm a 100% Linux user for the last 8 years and a fellow enthusiast. That said, I'm a web-app programmer and worry greatly about security. I have no idea about the internals of Linux or any other OS and really have no time to learn it. I NEED to be able to rely on people who know this part of CS.
So, with that said, and with honest and open intrigue: If to "...realistically secure a Linux system is almost impossible", then how does the internet not crash and burn? It is my understanding that most servers run on Linux, and their exposure to the internet makes them inherently extremely available for targeting. Are they all secretly compromised? Waiting for some global signal? Certainly, there are thousands+ of Linux-based VPS's out there set up by folks with only the most basic skills that have had sites up and running for years (self included). Are those just automatically pwned, and we can expect large swathes of the internet to stop working at any moment because the "dumpster fire" of Linux was used at the heart?
Should I switch my server to an Apple-based one so that I can benefit from the best security?
"Dependency slurping systems like NPM, CPAN, go get, and so on continue to freak me out. They might potentially be more dangerous than manual dependency management, despite the huge risks of that practice, precisely because they make it ‘easy’ to grow your project’s dependency graph — and hence the number of individuals and organizations that you implicitly trust. (And their trustworthiness can suddenly change for the worse.)"
Once you get past UEFI, installing Linux on a laptop isn't particularly difficult. The challenge is that drivers for wifi, audio, webcam, etc, will be very hit or miss depending on the hardware. My impression is that finding reliable drivers for BSD is even more difficult.
Are there laptops that are well supported by BSD (not including including MacOS)? Thinkpads maybe?
http://mainisusuallyafunction.blogspot.com/2012/11/attacking...
Oh man, that perfectly explains a formerly-unanswered question I had about how that mechanism worked. Thanks for linking.
i.e., transparent support of:
* I publish a public key
* Anyone can use it to send me an encrypted email
* I use my private key to read
* as a bonus, I sign my email with my private key
* anyone can verify with my public key1. Key distribution is a difficult problem. Where do you go to look up what the public keys are? The only obvious answer is the email provider, which brings us to...
2. Your email is already in practice secure from everyone except you, anyone with access to your email address, and your email provider. Your IMAP, SMTP, and POP connections are all secured with TLS anyways, and the MX connections between your email provider and your recipients' email providers are likely to be secured with TLS as well if at least one of them is Big Email Provider. (Even if that's not the case, this communication is occurring over the Internet backbone which is generally only tappable by the sorts of people who could probably get into your personal email account via other means anyways--the extra value is probably illusory).
3. Secure email doesn't actually secure any headers. Given that From/To/Date is going to be implicated by SMTP logs anyways, and these are the most useful headers for intelligence analysis, there's not much that oculd have been improved.
4. You lose the ability to do full-text search (or even header search, if you designed it to hide the headers as well).
5. Anti-spam measures become basically impossible with encrypted email; you'd have to push everything client-side, which is going to get annoying when you're trying spam detection on your smartphone for 10x the messages and you have to spend extra time decrypting each one.
6. Deploying any automated public-key infrastructure requires somehow automating the verification process. The verification process that can be automated is "this came from a person who has access to this email account," but the verification process that people want is "this came from the person whose name is associated with this email account," which we don't know how to automate.
What if all gmail and Microsoft email accounts came with a 4096 bit public key, with an option for the state DMV to verify the public key's association with a driver's license? I'm sure this would come with downsides, but would they be much worse than state DMVs using your gmail account to reset their web app passwords?
2. It makes it difficult for corporate oversight of employee emails.
3. Privacy is a differentiator only for a tiny fraction of the marketplace. So, there is very little profit incentive to invest the engineering resources to implement easy pub key into email.
2. How is it a straw man argument? I'm not saying it isn't possible, rather that it adds more complexity for little business value to companies.
Don't get me wrong, I'd love better email security/privacy. I went so far as trying SMIME for a year. I just don't see this situation improving.
I wasn't expecting the email protocol to change, just that I (my email client) would send / received cypher text (e.g., base64 encoded). The cypher text would be transmitted just like any other message.
Perhaps it could be worth considering that there could be complexities from another angle? Key discovery and management are complex tasks that require a working knowledge of PKI. These are also tasks that can be very dangerous to undertake in ignorance, as even a small mistake can lead to a full compromise. Is it possible that many users find these difficulties highly challenging?
Pretty much what we thought in the early days of PGP and key signing parties.
In practice, most emails between major domains will be encrypted over every public link. Only the two providers and the two parties will know either the contents or the metadata.
Whether you can trust the providers is a different discussion. But if you can't trust the companies, then you also couldn't trust most software either. The encrypting and decrypting have to be done somewhere.