LostKobrakai
After having watched the talk I’m wondering if this would also be a good opportunity to gather examples / tips about how to prevent or mitigate the mentioned issues. I’d expect the e.g. for the mentioned session issue there might already be examples out there. Also I’m especially curious about the last topic on mass assignment. How do you guys handle changesets which are allowed to change things like admin flags or alike, so at best they’re not accidentally usable from any frontend forms.
Trending in Talks
LT: Skode: an ASCII shorthand for audio experimentation - Joseph Stewart | ElixirConf EU 2026
Comments welcome! View the ...
New
How to Think About Game Servers (Pt 2)
Hernán Rivas Acosta looks at how latency and jitter affect multiplayer games and the techniques d...
New
Lightning Talk: Kate Rezentes - Notion-land | ElixirConf US 2025
https://www.youtube.com/watch?v=nLWm8gIz8TI
Comments welcome! View th...
New
Lightning Talk: Vito - An Absurd Situation with EPMD | ElixirConf US 2025
Comments welcome! View the <span class="hashtag...
New
Lightning Talk: Ivy Markwell - Data migrations with Monarch | ElixirConf US 2025
https://www.youtube.com/watch?v=AF1z6Z3bJKY
Comments ...
New
Testing Concurrency and Fault Tolerance in Elixir/Nerves - Marta Habdas | ElixirConf EU 2026
Comments welcome! View the <...
New
Practical Data Orchestration in Elixir - Silvia Zeamer | ElixirConf EU 2026
Comments welcome! View the <span class="hasht...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
griffinbyatt
I’ll comment with some of my thoughts a bit later when I have some more time. Until then, I wanted to say thanks for posting, and I’m happy to answer questions about the content if anyone has any!
LostKobrakai
I’ll start by adding my captain obvious solution to prevent accidental changes to admin flag fields: Don’t handle it through the params sent to
changeset/2, but only allow them to be changed by custom functions.This way in each places, where setting that flag should indeed be possible it has to be done explicitly, independent to any
changeset/2functions/params.griffinbyatt
The nice thing about most of the vulnerabilities I talked about is that Phoenix does a good job of pushing you in the right direction, so there often aren’t too many ways to make mistakes. This means that 1) Once you are aware of the issues, they become much easier to avoid, and 2) A lot of these issues are easy to detect in an automated fashion, so a tool like Sobelow can simply/reliably help you avoid them.
That leaves “logical” issues like session/auth handling and “mass assignment” type vulns. These tend to be less Phoenix-specific, and are common across applications. Mass Assignment vulnerabilities are a pretty classic Rails issue, and have been fairly highly publicized, but the Rails community still has issues with it. It’s a pretty hard thing to mitigate.
I think part of the problem people have w/ the changeset functionality is that, because the
changesetfunction is generated for you (and because it’s called “changeset”), thechangesetfunction feels very “official” and safe.^^ This is definitely a solid way to start dealing with sensitive fields! Another is to have a bunch of unique, very explicit changesets. E.g.
registration_changeset,admin_changeset.Also, when possible, explicitly passing params is a good move. For example, something like:
People tend to like this recommendation less b/c it can cause a lot of duplication. But I like it, because even if something unfortunate changes w/in the changeset function, you’re still safe
benwilson512
One person’s duplication is another’s de-coupling.
sillypog
I am trying out this approach to the “mass assignment” issue. I haven’t merged it in to my project yet so this is a good time for feedback
I have a plug called WhitelistParams that takes the name of the parameter to be filtered, and a list of acceptable fields for that param. So my UserController has this at the top:
User exposes its public_fields through a function which returns the @public_fields module attribute. The @allowed_fields attribute is a concatenation of the @public_fields and @private_fields arrays. I can certainly see an argument that the public_fields list is not the responsibility of the model but it seemed convenient since the fields must be listed in the model for casting changesets.
OvermindDL1
@sillypog
Good idea, do you have a hex package up of it, or want to PR it to Plug?
sillypog
I don’t yet. Assuming our team merges it, I’ll see how it goes here and apply it in some other cases. If it is easy to work with then I will put something together. I think there will be some edge cases in terms of handling parameters of different types - right now I’ve only tried it on a single map, such as:
michalmuskala
That’s exactly what changeset does, just as a plug rather than part of ecto, right?
sillypog
I think in the case of the User I have some fields that should not be available to the update route, but do need to make it into the changeset from other places. For example, User has a password_reset_code field that is set by a changeset, but I don’t want that field to be editable by passing it into update. Filtering that out in the controller seemed like the best solution.
sillypog
I think it is working the same way as changesets. It takes only the whitelisted fields from the map and replaces the existing param with those.
Nothing too fancy.