Live data from Hacker News

Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

gkoberger.github.io

31–40 of 86 posts

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#31
post #16
post #13

Earlier quoted context omitted.

I'm sure at the very least some of the sorts are incorrect and will brick your browser tab from an infinite loop or something.

Thats crazy talk everything on Stack Overflow is correct because it has the most upvotes.

But what if it’s the answer to the question how do you brick your browser tab from an infinite loop?

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#32
post #8
post #7

Earlier quoted context omitted.

That’s more or less what all iframed ads are. Plus most popular web sites load libraries for services where the site owners can’t easily see what’s happening under the covers. Google analytics would be an example of this, but there are many , and lots of sites use multiple such services.

I see what you're saying and I agree for the most part, but all that code is written by someone, reviewed (maybe), and put to some form of a production environment. The code in StackOverflow is usually just typed right into the answer box and submitted. I know I've edited answers where there were compilation errors in the accepted solutions! Not strictly relevant to JS of course.

This is unintentionally fucking hilarious. You already concede that review is a “maybe”... so we have to assume it won’t happen. So basically your argument boils down to web code meeting the high standards of being “written by someone” and put in “some form” of a production environment. Any http server on a routable ip address qualifies as “some form” of production environment.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#33
post #20
post #10

Is it just me, or do none of them sort this array correctly? ["zebra","apple","banana","5","bapple","banana","banana"] Correction, the page finally found this algorithm that sorts my array[1]. So I am disappointed with the verifier function on this web page and may need to submit a PR 1 - http://stackoverflow.com/questions/3730510/#3730579

That conversation about for..in - any JS experts that can say whether modules or other new advances will help with this? Not being able to use the standard functions on primitives because random other code messes with them sounds like pogo sticking in a minefield.

    for (let x of xs)
in more recent versions of JS is how you iterate an array without facing that prototype pollution problem.

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#36
post #28
post #26

Earlier quoted context omitted.

The standard attack in this case is that someone could steal your cookies (if they are Js cookies) or execute instructions on gkoberger.github.io without your permission, since that is the context. The way you would do this is create an answer to one of these questions on stack overflow that includes malicious javascript. However, it's kind of unlikely there is much you can do with it. Sometimes a site will share coo…

This is why GitHub uses a separate domain (github.io as opposed to github.com) for user sites.

Moreover, github.io is in the public suffix list, so it is effectively a TLD (foo.github.io is a different site from bar.github.io; they can't become same origin by means of document.domain).

The risk of eval() is giving control of the site data of foo.github.io to the author of a stackoverflow comment.

The warning is part of the fun, though.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#37
post #3

Hilariously awesome. I'm curious whether the multiple warnings about running untrusted code in the browser are necessary. I feel like all websites are already untrusted code, and the browser is quite well sandboxed and protected from anything too bad happening. What is the worst case scenario here for the user within the JS ecosystem, under known avenues of attack, not counting an unknown zero day browser exploit?

I run a Flatpak'd browser with limited privileges, so the worst that can happen is my `~/Downloads` folder gets messed up.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#38
post #27
post #3

Hilariously awesome. I'm curious whether the multiple warnings about running untrusted code in the browser are necessary. I feel like all websites are already untrusted code, and the browser is quite well sandboxed and protected from anything too bad happening. What is the worst case scenario here for the user within the JS ecosystem, under known avenues of attack, not counting an unknown zero day browser exploit?

Given that this site is not hosted on a domain where you have important session cookies (or where you’ve granted permissions like camera or location usage) I don’t see much problem with eval-ing untrusted code. Most of the common XSS threats just don’t apply here.

It's all fun and games until the next JavaScript sandbox busting zero day drops.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#39
post #16

Earlier quoted context omitted.

Thats crazy talk everything on Stack Overflow is correct because it has the most upvotes.

To be fair, I'd imagine the code in SO answers is less likely to be malicious than the code in adverts on most news websites...

We're a small tribe, you and I; our hunting ground for answers, the minified JavaScript from pop-up ads. The white-devil of SO will never understand the respect for code in it's natural environment. We love the challenge, the existential search for truth and purpose.

A Red-Tailed hawk cries in the distance.

Post reply on HN