News for hackers. Stuff that matters.
Re:How come PHP seems so much faster than Rust? by Avamander on Saturday September 28, 2019 @08:44PM (#21104174)
I don't like it from the security perspective, looking at just how many vulnerabilities PHP-based software has had, it's too trivial to create a XSS, SQLi, CSRF, LFI, RCE and many other classes of vulnerabilities. I think there are better options out there than on average give better results. Maybe it's just incredible selection bias I'm encountering \shrug.
Re:How come PHP seems so much faster than Rust? by meritt on Saturday September 28, 2019 @09:17PM (#21104328)
Your argument is a form of survivorship bias. You're not acknowledging all of the gaping security flaws in contemporary web-development frameworks. People were writing sloppy PHP before CSRF and XSS were even invented. Yet somehow, Python, Ruby and NodeJS have all had numerous CVEs despite those attack vectors being well known at the time a given framework was written.

You think SQLi was bad? You should spend some time thinking about the numerous attack vectors available today in nearly every GraphQL implementation where programmers can't move fast enough in adding it to their stack. Data exfiltration is no longer a flaw but a feature.

Re:How come PHP seems so much faster than Rust? by Avamander on Saturday September 28, 2019 @10:23PM (#21104609)
> People were writing sloppy PHP before CSRF and XSS were even invented.

It is very very easy to write sloppy PHP, definitely easier than in many other languages and default frameworks.

> You're not acknowledging all of the gaping security flaws in contemporary web-development frameworks. P

I'm very aware of them, basically none have (had) as many high-impact vulns as PHP-based stuff does.

> Yet somehow, Python, Ruby and NodeJS have all had numerous CVEs despite those attack vectors being well known at the time a given framework was written.

You're not acknowledging the orders of magnitudes difference between the impact of an usual PHP vuln and those you listed.

> You think SQLi was bad? You should spend some time thinking about the numerous attack vectors available today in nearly every GraphQL implementation

The flaws in others are a very poor excuse for flaws in a thing itself.

Re:How come PHP seems so much faster than Rust? by delfinom on Saturday September 28, 2019 @08:55PM (#21104215)
But plenty of those vulnerabilities are not the fault of the language but the frameworks written by others. You can just as easily create SQL injection attacks in a Rust program or Ruby program. You can just as easily introduce XSS/CSRF problems in any of them. Etc.
Re:How come PHP seems so much faster than Rust? by Avamander on Saturday September 28, 2019 @10:19PM (#21104590)
If the majority of frameworks for a language are vunerable it's the language's fault. Python definitely doesn't have that issue, Rust and Go don't either.
Re:How come PHP seems so much faster than Rust? by francislavoie on Saturday September 28, 2019 @11:57PM (#21104968)
> majority of frameworks for a language are vunerable

Where's your proof? Modern PHP frameworks are secure by default.

Re:How come PHP seems so much faster than Rust? by Avamander on Sunday September 29, 2019 @09:25AM (#21106902)
We're talking about the majority of frameworks that are being used, not about some newer versions 0.1% use. In the end arguing won't get neither of us anywhere, I get my livelihood from testing vulnerable software and you can keep writing software in PHP.
Re:How come PHP seems so much faster than Rust? by jtreminio on Sunday September 29, 2019 @01:28PM (#21108325)
Majority of frameworks in use are:

Symfony Laravel CodeIgniter CakePHP Yii Zend Slim

All of these can (and recommend) using either PDO with named parameters, or a full ORM for SQL work. Most came packaged with a PDO (Doctrine, mostly) by default but have always supported whatever you wanted to use.

Write shit code, win shit prizes.

Re:How come PHP seems so much faster than Rust? by beatgammit on Saturday September 28, 2019 @09:16PM (#21104325)
> You can just a easily create SQL injection attacks in a Rust program

I disagree, mostly on the grounds that string concatenation isn't very convenient, so it tends to be easier to do things "the right way" instead of hacking things together. Yes, you can do string concatenation using something like `format!(...)`, but at that point it's really similar to the correct solution that it's not really what you'd reach for by default.

And yeah, the community here is a huge part of it, and IMO languages can and should be judged by their communities. If a language's community promotes insecure solutions, that's a language that I don't want to use at my company because I don't want my employees following that example.

Re:How come PHP seems so much faster than Rust? by muglug on Saturday September 28, 2019 @09:03PM (#21104255)
It’s really easy to write PHP, which means that people who don’t know about escaping input write PHP.

While there are some web-focussed languages (vs frameworks) that deliberately make it hard for you to write that sort of code, barely anyone uses them.

Re:How come PHP seems so much faster than Rust? by horizone on Sunday September 29, 2019 @09:42AM (#21106971)
> It’s really easy to write PHP, which means that people who don’t know about escaping input write PHP.

Not trying call you out on this point, more it made me laugh. Our lead developer strips out characters that break his XML importer (lets just say they are standard common characters, heck, he changes chr(13) to a string so he can switch it back later because he doesn't know how to handle multiple lines in an XML value). People who don't know how to escape inputs / actually handle data properly are in every language. We cringe on a daily basis.

Re:How come PHP seems so much faster than Rust? by colshrapnel on Sunday September 29, 2019 @02:51AM (#21105536)
"escaping input" is a notorious delusion. And a bad one.

- it is not "input" must be treated, but, so to say - output. It's the destination that matters, not the source. By the time you get the input, you have no idea how and where it will be used. You can tell it right before the output (or, rather, better to call it "use") only. Say, you've got some input that didn't pass the verification and you will have to display it back in the HTML form. And if you already "escaped" it for SQL, it will be malformed. And vice-versa. Moreover, any data must be formatted properly before use, not just something that you tagged as "input".

- the word treated above is for a reason. Because the term "escaping" suggests some certain routine in PHP, which is the actual reason for numerous SQL injections.

Re:How come PHP seems so much faster than Rust? by muglug on Sunday September 29, 2019 @03:08AM (#21105581)
You're right, my wording was inexact - we must always escape strings that can be controlled in some fashion by the user.

I'm working on comprehensive taint analysis for PHP[0], and I'm spending a bunch of time thinking about how to automatically detect those dirty strings.

[0] https://psalm.dev/articles/psalm-3-and-a-half#taint-analysis