Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Watch expressions are easily hijackable #4220

Closed
Loirooriol opened this issue Sep 29, 2017 · 5 comments
Closed

Watch expressions are easily hijackable #4220

Loirooriol opened this issue Sep 29, 2017 · 5 comments

Comments

@Loirooriol
Copy link
Contributor

  1. Load http://example.com/
  2. Open the web console
  3. Enter eval = () => 0
  4. Open the debugger
  5. Add a new watch expression: 1

Result: 0
Expected: 1

@bomsy
Copy link
Contributor

bomsy commented Sep 30, 2017

Oohhh ...Thanks for the report!

@jasonLaster
Copy link
Contributor

Nice find @Loirooriol, this is a bug with the debugger server. You can see the same issue w/ the old debugger as well.

@Loirooriol
Copy link
Contributor Author

Oh, I thought the culprit was #4107 because it wraps the expression in an eval.

@jasonLaster
Copy link
Contributor

yep, good point... we do the same thing w/ the old debugger client as well.

@jasonLaster
Copy link
Contributor

jasonLaster commented Sep 30, 2017

so... this fixes it:

I think the eval is not needed. and actually quite scary

diff --git a/src/utils/expressions.js b/src/utils/expressions.js
index ec27dac..05e40e1 100644
--- a/src/utils/expressions.js
+++ b/src/utils/expressions.js
@@ -14,13 +14,13 @@ export function sanitizeInput(input: string) {
  * NOTE: we add line after the expression to protect against comments.
 */
 export function wrapExpression(input: string) {
-  return `eval(\`
+  return `
     try {
       ${sanitizeInput(input)}
     } catch (e) {
       e
     }
-  \`)`.trim();
+  `.trim();
 }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants