Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Securize: Increase isolation by stripping away prototypes #350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/klipse/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@
(set! secured-eval true)
(let [original-eval js/eval]
(j/assoc! js/window :eval (fn [src]
(original-eval (str "with (klipse_eval_sandbox){ " src "}"))))
(original-eval (str ";(function(){with (this){ " src "}}).call(klipse_eval_sandbox)"))))
(set! eval-in-global-scope js/eval)
(j/assoc! js/window :klipse_unsecured_eval original-eval)
(j/assoc! js/window :klipse_eval_sandbox (clj->js (zipmap the-forbidden-symbols (repeat {}))))
(j/assoc! js/window :klipse_eval_sandbox (clj->js (zipmap the-forbidden-symbols (repeat (js/Object.create nil)))))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viebel I think this one makes sense on its own as a change; I'm not entirely sure of the security implications though it does unhinge the forbidden symbols from the Object and Function prototypes…

#_(set! js/klipse-eval-sandbox (clj->js (zipmap (js/Object.getOwnPropertyNames js/window) (repeat {}))))
#_(doseq [sym permitted-symbols]
(aset js/klipse-eval-sandbox sym (aget js/window sym)))))
Expand Down