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

[Bug]: Can update env from other app_id #532

Closed
shiipou opened this issue Jan 19, 2024 · 2 comments · Fixed by #534
Closed

[Bug]: Can update env from other app_id #532

shiipou opened this issue Jan 19, 2024 · 2 comments · Fixed by #534
Assignees
Labels
bug Something isn't working released

Comments

@shiipou
Copy link
Contributor

shiipou commented Jan 19, 2024

What happened?

We can update an env from an other app_id if we just change in the URL the :env_id parameter.
It seems there is no check that the :env_id that is a children of the :app_id.

Also, if someone pay the subscription, everybody will be able to update the app using the API.
The authorize rules is a or if placed on the same function.

What browsers are you seeing the problem on?

Other (specify above)

Version

lenra/server:1.3.2

Relevant log output

def update(conn, %{"env_id" => env_id} = params) do
    with {:ok, _app} <- get_app_and_allow(conn, params),
         {:ok, env} <- Apps.fetch_env(env_id), # ←← Here 
         {:ok, %{updated_env: env}} <- Apps.update_env(env.id, params) do
      conn
      |> reply(env)
    end
  end
defmodule LenraWeb.EnvsController.Policy do
  def authorize(:update, %User{id: user_id}, %App{creator_id: user_id}), do: true
  def authorize(:update, %App{id: app_id}, %Subscription{application_id: app_id}), do: true
end
@shiipou shiipou added the bug Something isn't working label Jan 19, 2024
@jonas-martinez
Copy link
Collaborator

@taorepoara We might need to prioritise this issue.

@taorepoara
Copy link
Member

🎉 This issue has been resolved in version 1.3.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants