News for hackers. Stuff that matters.
Re:Show HN: Inspect questionable scripts before piping them ... by dotdi on Saturday May 16, 2015 @02:27PM (#9557090)
I am sorry, but I fail to see how this would be of any help.

It is known that piping unknown scripts to bash is a bad thing. So when somebody decides to pipe into bash, they are either (1) sure of the source or (2) completely clueless about what the hell they are doing. In case (1) there is no need for the tool, and in case (2) asking "do you really want to run this?" will not make any difference since they just typed 'curl <whatever> | sh' into their shell.

Re:Show HN: Inspect questionable scripts before piping them ... by draz on Saturday May 16, 2015 @02:43PM (#9557163)
This. What if OP inspected the script and highlighted potential harmful commands? Changes in security configurations, manipulation in critical libraries, start-up scripts, and so forth. Not sure how much that would help to the novice, but it's at least actionable (user can look the commands up and understand the implications.
Re:Show HN: Inspect questionable scripts before piping them ... by dotdi on Saturday May 16, 2015 @03:28PM (#9557308)
"What if OP inspected the script and highlighted potential harmful commands?" OP doesn't. Look at the code.
Re:Show HN: Inspect questionable scripts before piping them ... by dewey on Saturday May 16, 2015 @05:16PM (#9557654)
That's exactly what he says, he agrees with you and just offers a suggestion on how to improve the script.
Re:Show HN: Inspect questionable scripts before piping them ... by joepvd on Saturday May 16, 2015 @02:46PM (#9557169)
vipe[0] from moreutils is a bit more general purpose command than this. It does not dictate the receiving end. So you can quickly check and correct data between pipes. Nifty stuff...

[0]: https://joeyh.name/blog/entry/moreutils/

Re:Show HN: Inspect questionable scripts before piping them ... by Xavi on Saturday May 16, 2015 @05:11PM (#9557632)
Just brain storming... could another possible solution be to create a public list of hashes of well known scripts, and then write a small `sh` wrapper that verifies that hash of the script it's about to execute?
Re:Show HN: Inspect questionable scripts before piping them ... by sean-duffy on Saturday May 16, 2015 @05:13PM (#9557643)
You mean like... a package manager?
Re:Show HN: Inspect questionable scripts before piping them ... by Xavi on Sunday May 17, 2015 @01:22PM (#9560811)
Well a package manager does much more than verify downloads, but sure you can think of it as a single featured package manager.
Re:Show HN: Inspect questionable scripts before piping them ... by mekazu on Saturday May 16, 2015 @10:14PM (#9558413)
You shouldn't always trust even 'trusted' scripts due to the potential for various types of man in the middle attacks. True, though, that with all things being equal some scripts are more trustworthy than others, but if you're on a compromised network then you can't trust any.
Re:Show HN: Inspect questionable scripts before piping them ... by spb on Sunday May 17, 2015 @01:14AM (#9558812)
Interesting. I wrote a similar script, in Bash, for my meta.sh project: http://meta.sh/index.sh
Re:Show HN: Inspect questionable scripts before piping them ... by danieltillett on Sunday May 17, 2015 @01:42AM (#9558876)
There is a nice simple version here too https://gist.github.com/sunaku/f5f79e20b6f92ab1e524
Re:Show HN: Inspect questionable scripts before piping them ... by hawski on Saturday May 16, 2015 @06:15PM (#9557850)
I can't wait for a time when simple and universal sandboxing will be available with no need for root.

Just: $ sandbox 'curl http://whatever | sh'

With predefined permission profiles or interactive permission system.

Re:Show HN: Inspect questionable scripts before piping them ... by seanp2k2 on Saturday May 16, 2015 @09:56PM (#9558377)
What would it do which can't already be done with normal nix permissions and/or ACLs? The solution is to create a user account, like www-run or redis or Postgres or any of the other tons of things which already do this.

An even better idea is jails, or something like Docker.

Re:Show HN: Inspect questionable scripts before piping them ... by hawski on Sunday May 17, 2015 @01:50PM (#9560923)
What you present is not simple or universal. Nix permissions and ACLs are for file system access and sadly in Linux "everything is a file" is a lie.

Jails or Docker are practically heavyweight sandboxes and they need root access.

Re:Show HN: Inspect questionable scripts before piping them ... by ams6110 on Saturday May 16, 2015 @03:09PM (#9557248)
Why not just:

  curl ... | less
Re:Show HN: Inspect questionable scripts before piping them ... by bbrazil on Saturday May 16, 2015 @03:27PM (#9557304)
One potential issue is that you don't know you'll get the same HTTP response next time.
Re:Show HN: Inspect questionable scripts before piping them ... by ams6110 on Saturday May 16, 2015 @03:43PM (#9557350)
From within less, you can save to a file or pipe to a command, once you've inspected the payload to whatever degree you desire.
Re:Show HN: Inspect questionable scripts before piping them ... by thrownaway122 on Saturday May 16, 2015 @07:11PM (#9557997)
I'm not sure that this is as safe as you may think.

EDIT More info. Yes this is better than curl ... | sh. But less has a lot of functionality (more than you'd expect) and a carefully written script could exploit some of this.

Re:Show HN: Inspect questionable scripts before piping them ... by SmirkingRevenge on Saturday May 16, 2015 @10:42PM (#9558474)
Would that really be any different that downloading the script, then opening it with less/vim/whatever locally, which is typically going to be pretty safe, unless the script is accidentally executed somehow.
Re:Show HN: Inspect questionable scripts before piping them ... by thrownaway122 on Sunday May 17, 2015 @04:33AM (#9559217)
Well it is exactly the same.
Re:Show HN: Inspect questionable scripts before piping them ... by hartator on Saturday May 16, 2015 @10:09PM (#9558401)
Can you provide an example?
Re:Show HN: Inspect questionable scripts before piping them ... by thrownaway122 on Sunday May 17, 2015 @04:39AM (#9559236)
EDIT found link http://seclists.org/fulldisclosure/2014/Nov/74

Basically the tldr is that gnu less is a program that has been engineered to do a lot of things over the years and this has created attack surfaces which mean that if someone was to curl .... | less on a carefully designed payload it could allow the payload to obtain a shell.

I wasn't saying that it isn't safer just that it isn't totally safe.

Re:Show HN: Inspect questionable scripts before piping them ... by SmirkingRevenge on Saturday May 16, 2015 @06:26PM (#9557873)
`curl ... | <your favorite code editor, like vim or emacs> -` should work too.

Thats generally what I do when I encounter the curl -> bash instructions on the web.

Re:Show HN: Inspect questionable scripts before piping them ... by jordanpg on Saturday May 16, 2015 @04:35PM (#9557511)
I like the sentiment, but I kinda doubt that the group of folks who would inspect the script before running if only it wasn't so inconvenient to do so has many members.

We live in an era of unsigned images and arbitrary code. This is about time and money, and I don't think any amount of astonishment from the larger community is going to reverse that trend.