Live data from Hacker News

Ask HN: What's the best programming language to learn for security?

news.ycombinator.com

31–40 of 54 posts

Re: Ask HN: What's the best programming language to learn for security?

#31

The E language ( http://erights.org/ ) was designed to express smart contracts back before Bitcoin was invented -- really forward-looking and, to me, educational. You don't in the least need to know it for a career in the field, but it changed how I think about security. http://erights.org/elib/capability/ode/index.html is probably the best quick intro.

FWIW, Cap'n Proto (https://capnproto.org) is a cross-language network protocol based on E's design (with direct help from E's creator, Mark Miller). So if you're interested in E-style capability-based security but want to use a more mainstream language, consider taking a look at Cap'n Proto.

(Also Sandstorm (https://sandstorm.io) is a server platform implementing this model. Disclosure: I am the lead developer of both of these projects.)

Re: Ask HN: What's the best programming language to learn for security?

#33
post #30

Related: http://techcrunch.com/2015/05/02/and-c-plus-plus-too/ We fail to learn. Heartbleed. GHOST. The Android 4.3 KeyStore. Etcetera, etcetera, etcetera. C was and is magnificent, in its way. But we cannot afford its gargantuan, gaping security blind spots any more. It’s long past time to retire and replace it with another language. [...] So please, low-level programmers of the world, I beseech you (while, to be cl…

This is advice useful for architects and engineers, and would be preaching to the pen-testing choir.

It is necessary for the member of such a security company to think of the software that they learn is first a tool used to attack other software (Metasploit, Burp, hand-written tools such as WWMD, quick one-off, discardable code used during a test), and secondly to develop a deep understanding of how the software under test works.

And, as I and others have noted previously in this forum, not all of the dramatically-reported errors are due to the low-level nature of C. Some are glaring implementation-language independent protocol errors.

Re: Ask HN: What's the best programming language to learn for security?

#34
post #19

Look into python and play around with scapy... look into Perl and play around with Metasploit... know how to implement your own Tor hidden-service keyserver and how to make your own site use an SSL/TLS cert... before you have completed all four of these tasks you will have a good idea of the landscape and will have learned a lot, possibly answering your own question.

Metasploit is Ruby. In 10 years of consulting with a progressively larger and larger team, I'm not sure I ever saw someone use scapy. It's not that scapy is bad, so much as that direct targeted low-level packet manipulation is kind of a 90s problem statement.

Gotcha, thanks for the clarification. So then, I suppose my recommendation of learning Metasploit and looking into Perl/CGI/PHP/javascript site security features are certainly separate/more than one thing. My aim was to suggest some broad "security programming" fields/projects that are easy to get started in or get quick results with and contain enough documentation and specialty uses that allow them to be drilled down into specifically if that part of the landscape interests OP. Also, doing cool things with scapy is fast and easy and learning to write your own scapy code seemed to teach me a lot about packet security very quickly. I was assuming that if one is an autodidact, the things I listed will keep you busy reading/learning related subject matter and introduce you to some cool things and familiarize yourself with what's out there while getting visible/fast results with a tool chain rather than just learning for learning's sake. There's a certain balance between thinking and doing; with excess of either it's easy to lose touch with reality/scope. This is why, when people want to "learn Linux" for example, I find out what they're interested in and point them toward some projects/packages... rather than pointing them to general Linux documentation which often has new users feeling like they're reading Greek without examples, or leads to eyeglaze.

Re: Ask HN: What's the best programming language to learn for security?

#35

Earlier quoted context omitted.

Second this, but want to add: You don't necessarily need to be able to sit down and bang out quality C, but learning some C is a great way to understand how software works at a lower level than you'll get from Python or Ruby. On the other hand you can apply that understanding to more quickly and correctly understand what higher level code is doing and what risks it is taking. If you don't already have a good theoreti…

Would you do that by picking up a copy of K&R or would you have a more modern recommendation?

K&R is still a really good book that covers pretty much all of the language. Do note that it is very dated, and stylistically you should not try to emulate them. Looking at a modern C code base (I have heard redis is well structured) would be the best place to learn a modern style.

Re: Ask HN: What's the best programming language to learn for security?

#36
post #26

Earlier quoted context omitted.

Second this, but want to add: You don't necessarily need to be able to sit down and bang out quality C, but learning some C is a great way to understand how software works at a lower level than you'll get from Python or Ruby. On the other hand you can apply that understanding to more quickly and correctly understand what higher level code is doing and what risks it is taking. If you don't already have a good theoreti…

I think C++ and Rust are actually a bad idea here. Learn C. Don't bother with C++ until you've got C down. I mean, learn Rust if you want to write Rust code. But for the objective I'm addressing with C, you need C.

Agreed, in addition a lot (if not most) of the low level attack surface (drivers, kernels, web servers) are still written in C, it's still the lingua franca (with C++ somewhat second).

Re: Ask HN: What's the best programming language to learn for security?

#37
post #15

Depends on what type of security you want to get into. General Pentesting: Python or something higher level. Lots of library and tool usage (i.e. scapy, nping, nmap, metasploit) Application Security: Learn frameworks more than languages. How to work inside of Rails, Spring, ASP, PHP stuff, etc. Common security bugs that exist in these codebases, how to fix them, and how to recognize them. It is more important here HO…

+1 for Python.

I would also recommend learning Ruby, there are less tools written in it but Metasploit is and it's fairly important to have a good grasp of.

Re: Ask HN: What's the best programming language to learn for security?

#38
This is going to be something of a rant, but roll with it.

This is a controversial opinion, but I don't believe someone should be a security engineer or a security consultant until they are a provably competent software developer.

This harkens back to the analogy of writing and editing - how can you expect to perform competent source code review from a security perspective without having a deep understanding of programming? Even if you do not know a specific language you're reviewing (ideally you should, though), you can at least generalize your understanding to look for common patterns of insecure coding.

The reason why I stress this so emphatically is because, despite the fact that you are asking which programming languages to learn, my experience with the security industry is that most people just don't have much real programming experience, which is absurd.

There are many firms where they will bill out their consultants at $2000+ per day and their consultants couldn't build a simple Twitter clone if they were handed a complete spec.

I would much rather someone who can sit down and write a compiler and who has no security experience whatsoever than someone who knows all the payloads for XSS and how to find them manually. One of these people understands software engineering as a discipline and where it goes wrong, and the other is basically learning different "routes" without truly understanding everything under the hood. I can teach the person who writes compilers to find serious memory corruption vulnerabilities in a week. I can't teach someone who has never programmed to find subtle mass assignment flaws in Ruby/Rails.

This is not a straw-man dichotomy. Like 'tptacek said, it is absolutely necessary for you to have a programming background if you want to work in AppSec. And God help you if you try to work on security in firmware or embedded systems and don't have this background.

My personal opinion is that all security engineers should be senior software engineers. There is a good quote by Ryan McGeehan (former Director of Security at Facebook, then Coinbase, now Hackerone) where he explains that the most competent security engineers start out by fully mastering a particular discipline. After they hit that point, finding vulnerabilities becomes extremely easy. You don't need to memorize different payloads or routes or rote methods of testing. When you have written a lot of C you will understand a buffer overflow in a half hour (enough to really be dangerous, anyway).

Working in security without a lot of experience programming is like trying to ski a black diamond without having mastered all the fundamentals. Do not do it. It is entirely too fashionable in the industry to hire people who don't know what they're doing, please do not add to this.

Now that my rant is over - you should learn Python and C. Ruby and Lua are also good; most people you'll find in the industry will be doing scripting in Python. You should know C for its rich history and deep connection with the information security industry, and also because most of the interesting vulnerabilities will be found in software projects written in C.

Source: A few years of security consulting, and now working as a security engineer in FinTech.

Re: Ask HN: What's the best programming language to learn for security?

#40
post #17

I love a question with a simple right answer: (Ruby OR Python) AND C. You can skip C if you don't want to do low-level work (embedded, kernels, writing shellcode for memory corruption exploits). Only a small fraction of security people do this kind of work. You cannot skip (Ruby OR Python), even if you don't ever plan to do web work (which is a dumb plan anyways).

JavaScript/Node.js/modules are essentials now since Node is pretty popular. For example, many Bitcoin modules like Copay are written in JavaScript and not available in other programming languages.
Post reply on HN