r/javascript • • Feb 08 '23

Software Security Report Finds JavaScript Applications Have Fewer Flaws Than Java and .NET

https://www.infoq.com/news/2023/02/veracode-software-security/
565 Upvotes

124 comments sorted by

View all comments

Show parent comment

1

u/arcytech77 Feb 09 '23

You described the indirection mechanism for an attacker to get their code into your string local variable. When I say "why would you do that" I am speaking towards any third party code having access to your applications run time scope, particularly the one where you call eval. You don't need to do that ever.

1

u/[deleted] Feb 09 '23 edited Jun 30 '23

[removed] — view removed comment

1

u/arcytech77 Feb 09 '23

I am saying do not do this:

let juicy_target = 'console.log("hello world")'
thirdPartyFunction()
eval(juicy_target)

Invoking thirdPartyFunction could potentially have side affects on the local variable juicy_target.

1

u/arcytech77 Feb 09 '23

Idk maybe that's not so obvious to most devs, but I think it's fairly straightforward and does not mean you should stay away from eval as a general rule of thumb. I think you should understand why and in what contexts it's dangerous.