Live data from Hacker News

Show HN: Run unknown shell script with a line-by-line confirmation prompt

gist.github.com

61–70 of 86 posts

Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt

#61

What would be amazing is a tool that analyses the script first, figures out folders and files (and networking) it influences and allows to sandbox it accordingly. This script wants to modify: - /usr/local/program/* - /etc/program/* - $HOME/.program Do you want to execute this? [Yes/No] ..because you know, what happens when you execute a script that does rm -rf /usr in the 100th step?

Back on windows xp I ran a tool called black ice that did this.

Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt

#62
post #60

What would be amazing is a tool that analyses the script first, figures out folders and files (and networking) it influences and allows to sandbox it accordingly. This script wants to modify: - /usr/local/program/* - /etc/program/* - $HOME/.program Do you want to execute this? [Yes/No] ..because you know, what happens when you execute a script that does rm -rf /usr in the 100th step?

Such can be easily implemented on top of Docker filesystem overlays/snapshots. You just run the script in question e.g. in fresh Ubuntu container and then compare overlay directories to see what changed.

If you are happy with running it only once in the container, yes.

But if you run it first in the container to see whether is does anything bad and then run it on the host (or a more valuable container), no.

The script might check whether it runs in a container. It might depend on the wall clock time. On /dev/urandom, whatever. As somebody already mentioned, the halting problem. No can do.

Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt

#63

What would be amazing is a tool that analyses the script first, figures out folders and files (and networking) it influences and allows to sandbox it accordingly. This script wants to modify: - /usr/local/program/* - /etc/program/* - $HOME/.program Do you want to execute this? [Yes/No] ..because you know, what happens when you execute a script that does rm -rf /usr in the 100th step?

That sounds a lot like what maybe[1] does.

[1] https://github.com/p-e-w/maybe

Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt

#64
post #62
post #60

Earlier quoted context omitted.

Such can be easily implemented on top of Docker filesystem overlays/snapshots. You just run the script in question e.g. in fresh Ubuntu container and then compare overlay directories to see what changed.

If you are happy with running it only once in the container, yes. But if you run it first in the container to see whether is does anything bad and then run it on the host (or a more valuable container), no. The script might check whether it runs in a container. It might depend on the wall clock time. On /dev/urandom, whatever. As somebody already mentioned, the halting problem. No can do.

doesn't the halting problem only hold if you have infinite memory?

Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt

#65
post #64
post #62

Earlier quoted context omitted.

If you are happy with running it only once in the container, yes. But if you run it first in the container to see whether is does anything bad and then run it on the host (or a more valuable container), no. The script might check whether it runs in a container. It might depend on the wall clock time. On /dev/urandom, whatever. As somebody already mentioned, the halting problem. No can do.

doesn't the halting problem only hold if you have infinite memory?

That's probably correct. But any reasonable execution environment has so many states that doing a full enumeration is infeasible.

Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt

#66
post #57
post #34

Earlier quoted context omitted.

Because that's an unrealistic threat model for most users.

I think the most realistic threat model right now is "subverted browser extension", which is effectively equivalent to internet-wide XSS. Luckily I've only been hit once, and with adware, but it's a risk.

A browser extension is not a threat model, I'm not sure what you mean.

Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt

#68
post #64
post #62

Earlier quoted context omitted.

If you are happy with running it only once in the container, yes. But if you run it first in the container to see whether is does anything bad and then run it on the host (or a more valuable container), no. The script might check whether it runs in a container. It might depend on the wall clock time. On /dev/urandom, whatever. As somebody already mentioned, the halting problem. No can do.

doesn't the halting problem only hold if you have infinite memory?

I've seen this argument that 'halting problem is undecideable': http://www.lel.ed.ac.uk/~gpullum/loopsnoop.html

The argument doesn't rely on infinite memory.

Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt

#69
This is exactly what deno is useful for. Write your script in typescript and then run it with deno --prompt.

I made a little demonstration script.

    deno run --prompt https://crux.land/4Lc2E2
Spoiler: https://share.getcloudapp.com/ApuYR00w if you can't run above.

Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt

#70
post #66
post #57

Earlier quoted context omitted.

I think the most realistic threat model right now is "subverted browser extension", which is effectively equivalent to internet-wide XSS. Luckily I've only been hit once, and with adware, but it's a risk.

A browser extension is not a threat model, I'm not sure what you mean.

Browser extensions are an attack surface, examination of which is a key aspect of threat modeling.
Post reply on HN