5 ms·
The React2Shell Story
- keyle 5mo agoNice read! I love the "we are so back" vs. "it's so over" graph. Defines so much of this type of work. "Wow? ... nah... WOW?! ... nah..."
- Rauchg 5mo agoR2S was a painful one, but Lachlan was a dream of a security researcher to partner with. Not just from a responsible disclosure POV, but things like hopping on multiple calls with Meta and our team to help us validate remediations. Thank you Lachlan for helping make the internet safer (and great job on figuring out this 'labyrinth' of a vulnerability)
- owebmaster 5mo ago[flagged]
- halflife 5mo agoReact was ruined from the moment they abandoned class components and introduced hooks. Vercel is just continuing the trend of hype against common sense.
- ervine 5mo agoI just don't understand this take, every time I hear it I wonder if people just haven't spent the time to adjust their mental model. Hooks are IMO the best thing that happened to react.
- pjmlp 5mo agoI have spent more time than I wished for on React debugging tools, and useXXXX spaghetti calls.
- ervine 5mo agoYou can write spaghetti with class components, too. Doesn't sound like a hooks issue to me.
- pjmlp 5mo agoI certainly can, but somehow it cooler to write lambdas upon lambdas, and other Haskellisms when using hooks.
- ervine 5mo agoI think we're just gonna agree to disagree. Cheers.
- halflife 5mo agoOf course, the only question is in what way the programming language pushes you. You can TS code where every variable is assigned “any” type, that would void all type safety. Is it possible? Yes. But someone needs to bend the languages will to do that. Classes have inherent state, and methods which encapsulate logic. That pushed you to create separate logic bundles. Functions are callable scripts. There are no rules. I’ve seen too many components that invoke tens of hooks, and hundreds of lines of state management. Most classes I’ve seen never reached that. Were there classes that were too big? Of course, but at least there was logic separation with methods.
- bobthepanda 5mo agoThe great sin of the migration to hooks was that the docs were so poorly written that everyone got into bad habits. You can have self documenting state like class components in the form of reducers which are just state machines. But it is much later in the documentation.
- halflife 5mo agoI’ve done plenty of hooks. Also class components. Also angular. You are writing code for an object that is inherently stateful, in a stateless design pattern. Instead of embracing state, you crate escape hatches and plugins to tap into your state, and then more escape hatches inside those escape hatches to tap out. It’s react rendering model leaking into your code. Let’s imagine react changes the rendering paradigm, and components are rendered once with only state updates. Almost all of your hooks become useless. The fact that you need to think about react internal every time you create a component is such a bad API choice that I’m amazed it still exists, and being expanded.
- ervine 5mo agoSo your argument is that instead of explicit class component methods, hooks are implicit based on understanding the react rendering model? I guess so - but react could also change (and I think did at some point) how their class methods work, how often they're triggered, and when. I don't understand the stateless comment - hooks are as stateful as you make them, using useState or useContext or any of the other ways of maintaining data between renders.
- halflife 5mo agoClasses are inherently stateful. A class instance is a long lived object. Functions are not, a functions internal state is thrown the moment the function returns. What react ask you to do is to attach to external state inside the function, in other words, an un pure function, forego idempotency. In class based components, you didn’t care how react works under the hood, except for the render method which is called by react. So the surface of code controlled by react was only what you included inside that method. In function components, the entire function is owned by the renderer, so you need to deeply understand how it works.
- ervine 5mo agoI guess I think it's table stakes to need to deeply understand how the framework you're using works. Lifecycle methods vs. hooks, you still gotta know what's doing what and why.
- pjmlp 5mo agoSpot on, incredible how OOP hate can mess up a framework. Vercel, the only thing they have going for the app model mess, are the partnerships with SaaS vendors that make them the must go tooling. However this will eventually come to an end.
- ervine 5mo agoIt wasn't OOP hate, it was hatred of splitting functionality across a number of methods rather than putting it in a single (reusable, sharable!) hook and having your component consume it.
- pjmlp 5mo agoYeah, because now is so much better.... I only touch React now, because of SaaS partnerships with Vercel. Otherwise I pretend it doesn't even exist.
- littlecranky67 5mo agoYou are probably a Javascript dev, not doing typescript? Classes were horrible to type for, especially when you tried higher-order components. Hooks removed so much clutter and friction and allows pretty well-typed components and higher order functions (i.e. hooks that return components).
- epolanski 5mo agoYes, they were uglier but they had advantages that got lost such as an easy to control rendering life cycle. Just opening dev tools on MIT-written big tech corps and startups confirms nobody is able to write good websites or applications that arent filled with performance and memory leaks.
- Sankozi 5mo agoHooks made simple things simpler, but hard things harder, code with lots of boilerplate was replaced with code with leaky abstractions full of various workarounds - I don't think this is a good trade. While I hate class component lifecycle methods they are much better than complex hook setups when solving more advanced problems.
- halflife 5mo agoJust having an interval inside a component used to be trivial, but with hooks becomes tedious. Only the barebones simple ultra basic stuff became simple. Everything else? Harder.
- b4ckup 5mo agoCould you elaborate why you dislike lifecycle methods? I read this take a lot and I use mainly angular but did some smaller projects with react class components and with function components. I also think function components are very counter intuitive but I also never had anything against lifecycle methods.
- Sankozi 5mo agoThey often require quite complex ifology for simple use cases. Also didmount and diduptade often needs to be overriden together only to have almost the same implementation. They also have some gotchas regarding state updating inside them.
- dang 5mo agoYou can't attack another user like this here, so please don't. It's particularly bad when someone shows up to discuss their work and commenters take the opportunity to attack them. That's a mob dynamic, and we don't want those here. It also strictly worsens the site because it gives people a disincentive to contribute in precisely the areas they know the most about. I've been trying to explain this for years: https://hn.algolia.com/?dateRange=all&page=0&prefix=true&query=by%3Adang%20disincent&sort=byDate&type=comment https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
- simonreiff 5mo agoWhat a great write-up. Thanks for sharing how you found this fascinating vulnerability and exploit.
- sam1r 5mo ago>> Amazingly, despite being a weekend, the Meta team triaged, reproduced, and confirmed my submission in around 17 hours. Incredible. Realize what you have done from start to finish (with confirmation) in < 24 hours.
- phyzome 5mo agoHaha, nice. One correction: The link in "To be honest, I'm not even sure if I understand it, but it's on my GitHub." goes to the wrong file (01 instead of 00).
- mnahkies 5mo agoI was really surprised when this hit, and I discovered the protocol was essentially undocumented / unspecified. I was trying to find indicators of compromise and that was made more difficult by the lack of documentation. It was really helpful that they had coordinated with WAF providers like cloud flare ahead of disclosure to put rules in place though.
- halflife 5mo agoWhoda thunkit that - blurring the lines between client code and server code - creating a brand new protocol for communication between trusted and untrusted actors - and with all of that allow the protocol to serialize code and not just primitives Would be a tremendously stupid idea. And for what? To lock developers further into the react ecosystem. What a shitshow react continues to be.
- owebmaster 5mo ago> And for what? To lock developers further into the react ecosystem. It was a clear bait and switch scam, that is still going on.
- ascorbic 5mo agoA great read. Sylvie's writeup is good too: https://sylvie.fyi/posts/react2shell/ https://sylvie.fyi/posts/react2shell/
- mexicocitinluez 5mo agoSide note: A few weeks ago I started to see floaters in my eyes and the background for your site is making my brain go haywire. Also a tad bit distracting while trying to read the article. Really cool article btw.
- NewLogic 5mo agoI'm still yet to be convinced React Server Components are anything but a disaster to the developer experience. Mixing backend and frontend without a clear boundary is terrible for any codebase beyond a handful of contributors.
- pjmlp 5mo agoBut it is so cool! I really don't understand why people complain about Spring or ASP.NET annotations, and then go running to Next.js with its useXXX and import magic.
- mejutoco 5mo agoSpring is a very good analogy to what useX hooks were to react. Thank you for this. A different dsl inside Java or js implemented with duct tape in a dynamic way. React was screaming for a real typed functional language like elm imo, instead of a kludge of abstractions enforced by linters and weekly-changing best practices. React should have been "finished" like jquery. It is possible to develop something solid in it of course, but elegant it is not. Full of leaky abstractions.
- Vinnl 5mo agoThe prime motivator for it is a certain user experience. I'm not sure they've found the best developer experience for providing that user experience, but I'm also not sure that a better DX is possible - the whole concept has quite a bit of inherent complexity, I'm afraid. (The conclusion could, of course, also be that it's just not feasible to create that kind of user experience. Luckily, traditional patterns still work just as well.)
- andrewingram 5mo agoIf you look at the origins, the primary motivation was finding a way to get a good data loading developer experience without having to adopt Relay and GraphQL.
- switz 5mo ago
- vessenes 5mo agoBoy I loved this write up, and really loved Sylvie’s, which gives a peek into the economic side of this white hat hacking — prepping, safety, wondering who you trust, preparing to claim as many bug bounties as possible. I was struck by the very sensible economic filter: “who is vulnerable that has a bug bounty program?” Incredibly good reminder that you should have a bug bounty program; otherwise, nobody might call you. Until, you know, you’ve been compromised.
- nkrisc 5mo agoI wish this site respected prefers-reduced-motion. The dots on the background give me motion sickness while trying to read. Thank goodness for Firefox reader mode.
- BlackEspresso 5mo agoReally nice writeup. Would be intresting If an ai can find such vulns, too.
- tosti 5mo agoThe first exploit looks somewhat like an elaborate json version of the bf language.
- ryanschaefer 5mo ago> But that afternoon, fueled by curiosity and frustration, I felt a switch flip in my brain, and I dived head-first into a rabbit hole with no turning back. https://xkcd.com/356/ https://xkcd.com/356/ It happens to all of us. However, I think it’s much easier nowadays with LLMs for something productive like this to come out of it. I can notice something wrong and triage or even fix it before the point where I’d normally start to feel the subconscious pull of opportunity cost telling me to stop.