braunse

braunse

Sobelow CSWH check, unsure about the validity of its finding

I created a new LiveView application and installed sobelow, which immediately gives me a finding of:

Config.CSWH: Cross-Site Websocket Hijacking - Low Confidence
File: lib/my_project_web/endpoint.ex
Line: 18

which refers to the LiveView socket:

socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]]

So to solve a potential problem, I added a check_origin: true option to the websocket options, but the finding is still there. Looking at the source, it seems that the finding will always be present, if there are any websocket options given as a keyword list, regardless of whether the origin is checked or not. Only the confidence varies:

  defp check_socket_options([{:websocket, options} | _]) when is_list(options) do
    case options[:check_origin] do
      false -> {true, :high}
      _ -> {true, :low}
    end
  end

I’m uncomfortable ignoring security warnings without grokking why the warning is there in the first place, so I’d definitely like to understand this more. Would checking the origin not actually solve the problem? Am I misunderstanding something about the vulnerability? Or should I open a pull-request to insert a true -> {false, :high} clause?

Marked As Solved

braunse

braunse

Replying to myself for future reference, this was fixed in fix: Add checks for nil and true socket options · nccgroup/sobelow@5005246 · GitHub which is included in sobelow 0.10.5.

Also Liked

voltone

voltone

I’ll leave it to @griffinbyatt to give the definitive answer, but in general it is virtually impossible with static analysis alone to rule out false negatives (or positives). Full data flow analysis would require concolic testing or IAST-style runtime verification of findings.

Sobelow is probably erring on the side of caution, flagging the use of a feature that requires special security considerations. The low confidence finding is saying that everything appears to be configured correctly, while still raising awareness of the potential risk.

braunse

braunse

I’m a security person in my day job, so I know about the limitations of static analysis, and I totally get raising awareness. But the way this check works, it doesn’t feel to me that this is what’s happening here: Why is there no finding if I simply say websocket: true instead of websocket: [...options...] in the socket call? Case in point: the default socket "/socket" ... two lines up does not get flagged:

socket "/socket", CaplaWeb.UserSocket,
    websocket: true,
    longpoll: false

This is why I’m confused: If one of these lines needs awareness, then surely both of them need it? Or am I missing the point?

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement