Antigravity.py (2020)
Waterluvian 2021-08-16 15:02:45 +0000 UTC [ - ]
This is in the python standard library. So you can open a python REPL and type `import antigravity`
tersers 2021-08-16 14:04:13 +0000 UTC [ - ]
boublepop 2021-08-16 18:22:58 +0000 UTC [ - ]
mxuribe 2021-08-16 14:21:38 +0000 UTC [ - ]
I was looking at the "Automate the Boring Stuff with Python" book by Al Sweigart (which admittedly i have not read cover to cover, but rather use it as a reference) for some help with a little polite scraping, and lo and behold the webbrowser module...See chapter 12: https://automatetheboringstuff.com/2e/chapter12/
I have not played much with it yet, but man, python continues to impress me!
codetrotter 2021-08-16 14:17:01 +0000 UTC [ - ]
Tried it on my MacBook M1 and it opens Brave which is my main browser.
Wonder if it's using the same mechanism as the macOS open(1) command does for opening URLs. Or maybe even calling the /usr/bin/open binary.
zirak 2021-08-16 14:35:33 +0000 UTC [ - ]
It seems to be shelling out to osascript, either telling it to OpenURL or open.
jp_sc 2021-08-16 14:56:37 +0000 UTC [ - ]
You can use this library for that: https://pypi.org/project/texteditor/
(Disclaimer: I’m the author)
diogenesjunior 2021-08-16 14:58:25 +0000 UTC [ - ]
jp_sc 2021-08-16 15:01:34 +0000 UTC [ - ]
There are several cases when you would want to do that, for example, think on the git CLI, that opens one so you can write a commit message, etc.
And is not only about using the EDITOR variable, most non-programmers doesn’t have one defined or it points to vim or something equally terrible for non technical users.
BiteCode_dev 2021-08-16 15:04:05 +0000 UTC [ - ]
ehsankia 2021-08-16 15:08:03 +0000 UTC [ - ]
szszrk 2021-08-16 14:23:23 +0000 UTC [ - ]
chronolitus 2021-08-16 16:32:35 +0000 UTC [ - ]
First, the line
webbrowser.open("https://xkcd.com/353/")
is obvious, it opens a browser pointing to the relevant XKCD comic, containing a joke which inspired this code.
Then, a geohash function is declared which takes the user's current latitude/longitude, and the current date-time, and returns a target latitude/longitude. According to a previous comic (https://xkcd.com/426/) this corresponds to the game of 'geohashing' where players are supposed to physically travel to arbitrary locations and prove it.
nwsm 2021-08-16 17:34:48 +0000 UTC [ - ]
This is not to be confused with a geohash [1].
diogenesjunior 2021-08-16 14:10:06 +0000 UTC [ - ]
TypeError: openssl_md5() takes no keyword arguments
shmageggy 2021-08-16 15:08:53 +0000 UTC [ - ]
> Changed in version 3.9: All hashlib constructors take a keyword-only argument usedforsecurity...
geofft 2021-08-16 16:15:12 +0000 UTC [ - ]
glofish 2021-08-16 15:28:26 +0000 UTC [ - ]
https://en.wikipedia.org/wiki/Geohashing
and
official website:
https://geohashing.site/geohashing/Main_Page
oddly the geohash function in the antigravity module prints to the screen rather than returning the values ... seems odd to say the least
Xavdidtheshadow 2021-08-16 22:07:07 +0000 UTC [ - ]
That was a favorite activity of mine in high school. On Friday evening, we'd look at the nearest graticule(s) to our town and pick one for a Saturday day trip. Trucking out to a random point on a map is a great way to explore your metro area and see things you never would otherwise.
Heartily recommend trying it out. Looks like the map (linked from the comic) is no longer working: http://carabiner.peeron.com/xkcd/map/map.html
But, with this function, there may yet be hope!
raymondh 2021-08-17 00:00:04 +0000 UTC [ - ]
chha 2021-08-16 13:00:30 +0000 UTC [ - ]
codetrotter 2021-08-16 14:11:34 +0000 UTC [ - ]
webbrowser.open("https://xkcd.com/353/")
isp 2021-08-16 14:20:15 +0000 UTC [ - ]
See "Hacking with Environment Variables", which specifically exploits the antigravity module for arbitrary code execution - https://www.elttam.com/blog/env/#content
Previous HN comments: https://news.ycombinator.com/item?id=23828045
oyf 2021-08-16 16:20:53 +0000 UTC [ - ]
You could set PATH to change which files are executed in certain scenarios. You could set SSLKEYLOGFILE which logs session keys to an arbitrary file, essentially nullifying TLS/SSL protections. On Linux you can just set PROMPT_COMMAND to whatever you want and it'll be executed any time a bash prompt is printed.
It's an interesting attack vector, but a vulnerability requires impact, and I'm not sure this has very much.
thebeardisred 2021-08-16 15:28:48 +0000 UTC [ - ]
https://git.savannah.nongnu.org/cgit/man-db.git/commit/src/m...
Turns out it was breaking a users automated tests - https://unix.stackexchange.com/questions/405783/why-does-man...
2021-08-16 14:56:00 +0000 UTC [ - ]
chias 2021-08-16 15:06:20 +0000 UTC [ - ]
Remember: you have control over only the environment variables, and you do not have the ability to alter the arguments. In order for this to represent arbitrary code execution, you need for the system to have an executable on it that, when executed with the argument "https://xkcd.com/353/", grants you arbitrary code execution.
So, you have full control over the environment variables, and that's it. How do you turn effectively
into arbitrary code execution, where [binary] is an executable already on the machine?isp 2021-08-16 15:15:04 +0000 UTC [ - ]
geofft 2021-08-16 16:19:53 +0000 UTC [ - ]
In this particular case, they happened to be in a situation where they couldn't easily figure out how to create new files but they could set environment variables. From a design perspective, as a reviewer, I would not believe that this makes it safe to have attacker-controlled environment variables, although I admit I wouldn't know exactly how (and this post is a pretty clever approach to making the attack work).
btown 2021-08-16 15:41:03 +0000 UTC [ - ]
dpwm 2021-08-16 15:52:13 +0000 UTC [ - ]
What cause would there be to import antigravity in a CGI service – or anything other than a terminal in which you could already execute arbitrary code?
I am struggling to understand, even with the proof of concept, how the situation could arise where an attacker could realistically exploit this, based largely on the uselessness of the antigravity module.
geofft 2021-08-16 16:41:53 +0000 UTC [ - ]
dpwm 2021-08-16 17:13:38 +0000 UTC [ - ]
There are multiple failings that don’t seem like a big deal taken in isolation:
- The PYTHONWARNINGS and whole Warning Filters system.
- The webbrowser module executing a given executable from an environment variable.
- The antigravity module running webbrowser.open() on import.
All of these sort of seem a bit like sacrificing good taste for convenience. But in combination, in a situation where you don’t control the environment variables, they do lead to arbitrary code execution.
In other words, it’s not all antigravity’s fault, but those side effects on import make this possible.
kzrdude 2021-08-16 21:16:28 +0000 UTC [ - ]
jvanderbot 2021-08-16 16:28:41 +0000 UTC [ - ]
dpwm 2021-08-16 17:53:57 +0000 UTC [ - ]
Add the not-too-far-fetched-seeming assumption that it’s fine to let the Internet define your environment variables, and it’s a plausible exploit.
This is why, as another commenter points out, defense in depth is so important.
ASalazarMX 2021-08-16 15:32:52 +0000 UTC [ - ]
tyingq 2021-08-16 15:58:01 +0000 UTC [ - ]
shaded-enmity 2021-08-16 15:47:47 +0000 UTC [ - ]
chias 2021-08-16 15:43:05 +0000 UTC [ - ]
2021-08-16 15:16:44 +0000 UTC [ - ]
marcinzm 2021-08-16 15:34:18 +0000 UTC [ - ]