-
My expectation is the shared library functionality will be very popular (for some definition of "very popular") in web development circles, as it will function both in the browser via WASM and server via shared library. Until we have a proper C-API for constructing values, we are currently limited to providing strings to the Scryer process. For some users, it would be very easy to do something like: with scryer_process() as wam:
results = wam.eval(f"input_searchresults('{user_input}', Results).") perhaps not realizing they are inviting remote code execution or cross site scripting vulnerabilities. It would be good to advise what the correct way of reading user input is -- I'm not even sure myself! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 14 replies
-
If Scryer runs as a library then conceptually speaking the caller is responsible for doing string sanitization. I see at least 2 types of possible problems:
|
Beta Was this translation helpful? Give feedback.
-
I think reversing @bakaq 's algorithm in PR #2493 is probably the key to a convenient API that doesn't expose the user to string injection attacks. It might not be the best "Prolog" approach but from a shared library perspective it would be perfect, and it would be a good stepping stone to the C-API. |
Beta Was this translation helpful? Give feedback.
-
A general remark. When you do the following: wam.eval(f"input_searchresults('{user_input}', Results).") Then If you want a secure interface then possibly some other approaches are needed as discussed here. P.S. This problem isn't Prolog specific, you will have all exactly the same vulnerabilities if you would like for example embed JavaScript into your application. |
Beta Was this translation helpful? Give feedback.
-
Having progressed a little further with Prolog, the answer and suggested best practice now is fairly clear. Simply take a user input, then
|
Beta Was this translation helpful? Give feedback.
Having progressed a little further with Prolog, the answer and suggested best practice now is fairly clear. Simply take a user input, then
call/N
on the result of bullet [1] or [2] and you will be fine.