You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Meaning that it analyzes the raw code as a string and not the final compiled code.
Here is a trivial example that would bypass the XSS checks:
defmodule RouterHack do
quote do
plug(:accepts, ["html"])
plug(:fetch_session)
plug(:fetch_flash)
plug(:put_secure_browser_headers)
end
end
end
defmodule MyApp.Router do
use MyApp.Web, :router
pipeline :browser do
require RouterHack
RouterHack.get_browser_pipeline()
end
end
Since sobelow is only checking the original code as a string, this macro is completely unchecked and is allowing the security vulnerability.
This is an easy way to bypass the sobelow security checks, and macros can live pretty unchecked. With a language like Elixir; which is macro heavy, really devalues what sobelow provides.
I recommend investigating a way to inspect the generated beam files (as the dialyzer works) or see if the core team can add a function that returns the generated AST before beam file generation (if there isn't one already. I dug around for an example and I couldn't find anything, but that doesn't mean it doesn't exist).
The text was updated successfully, but these errors were encountered:
I agree that some kind of macro expansion would be nice. Though, I think operating on beam files directly would end up being a worse experience, since you may lose the context you get from operating on AST directly.
This is something I toy with from time to time, but it isn't high priority. The vast majority of the time, with common and semi-common configurations, the lack of expansion will result in false positives rather than false negatives. And someone deliberately attempting to bypass the security checks is not within the scope of the tool.
Aside - in your example, which XSS checks are being bypassed? I think the outcome from your example would be a false positive about secure headers, and a false negative for CSRF.
Haha. Sorry about that, I gave you a pretty out of context example unless you memorized the phoenix plugs. The example is missing the plug(:protect_from_forgery) plug.
Due to the way sobelow checks for vulnerabilities, it reads the raw code into a string and converts the string code to elixir AST:
sobelow/lib/sobelow/config.ex
Line 80 in 26589a5
sobelow/lib/sobelow/parse.ex
Line 41 in 8702702
Meaning that it analyzes the raw code as a string and not the final compiled code.
Here is a trivial example that would bypass the XSS checks:
Since sobelow is only checking the original code as a string, this macro is completely unchecked and is allowing the security vulnerability.
This is an easy way to bypass the sobelow security checks, and macros can live pretty unchecked. With a language like Elixir; which is macro heavy, really devalues what sobelow provides.
I recommend investigating a way to inspect the generated beam files (as the dialyzer works) or see if the core team can add a function that returns the generated AST before beam file generation (if there isn't one already. I dug around for an example and I couldn't find anything, but that doesn't mean it doesn't exist).
The text was updated successfully, but these errors were encountered: