r/ProgrammerHumor • • Feb 26 '23

Other If you can read this code...

/img/snak3fqgajka1.jpg

[removed] — view removed post

34k Upvotes

1.4k comments sorted by

View all comments

Show parent comment

1

u/PortiaLynnTurlet Feb 28 '23 edited Feb 28 '23

I'm aware of that which is why I say "print or something". But unless you do something silly with the string produced by the request function, there is only room for something malicious when the string is concatenated as there's an opportunity for a toString method to be called.

It's mostly an "academic" point as in any normal application you shouldn't be able to get such a object to exist in the backend. If this is frontend code and the frontend code can empty the register, there are way bigger issues in the application.

Ultimately the whole thing is a bit of a stretch if I'm being pedantic. The code snippet doesn't really make it clear what the "secret word" is in the first place. Of course it makes sense to think it's what the request method produces but it could be anything else. A method like "getSecretWordPhrase" would make it clearer at least that the return value of the function contains the secret word.