A bit of a bizarre post since to_sgid has existed forever to generate signed global ids. Global IDs are probably one the most powerful and underrated features of Rails but regular global ids are only supposed to be used internally (e.g. job params) and never sent to the client.<p>If there’s a gotcha it’s that _signed_ global ids are only signed, not encrypted, and very few people seem to know about the optimised method (globalid::Locator.locate_many) for loading a batch of global ids
If you don't want invoice 22 to be shown by someone putting 22 on the url, you definetly need to enforce permissions on your app. The Global ID issue is tangential to that.
This title is odd, given the actual identified problem seems to be LLMs writing code.
> GIDs are not checked for authorization when doing the lookup - they are meant to be generated above the authorization layer, and to be consumed above the authorization layer<p>Then the problem with this post boils down to applying the authorization layer in any tool call, just like you do in controllers. Seems obvious?
So....LLMs can hallucinate GIDs. I hope that everyone is aware of that.
Rails is a dangerous place to be throwing random data into APIs.
Any popular Rails apps that use to_global_id?
Almost any modern rails apps that have a job queue will use this at some point
Shopify: <a href="https://shopify.dev/docs/api/usage/gids#global-id-structure" rel="nofollow">https://shopify.dev/docs/api/usage/gids#global-id-structure</a>
Shopify <a href="https://shopify.dev/docs/api/usage/gids" rel="nofollow">https://shopify.dev/docs/api/usage/gids</a>
The built-in ActiveJob api uses them.
the AI hallucinated and somehow it's rails fault?<p>GID's are great - i think the issue is with how they leveraged rubyLLM for something they should inherently not be using LLMs for.<p>> Remember that GIDs were made for facilitating ActiveJob serialization - they are a system-level facility, not a product-level facility.<p>I think this is somewhat obvious given the signature like gid://awesome-app/Post/32; there is no scoping to the user or account so it should be treated like a global lookup. If you need scoping to a user/account you can build that.<p>Honestly I think this is a matter of the author using poor design decisions and over leveraging LLMs. But this is not the fault of Rails, it is working as expected.<p>Be careful with LLMs!