7 ms·
Sometimes CPU cores are odd
- ranger_danger 1y ago> In retrospect implementing the proof of work challenge may have been a mistake Why? What would the alternative have been?
- tux3 1y agoIt does two things: Force everyone (including scrapers) to run a real JS engine, and force everyone to solve the challenge. The first effect is great, because it's a lot more annoying to bring up a full browser environment in your scraper than just run a curl command. But the actual proof of work only takes about 10ms on a server in native code, while it can take multiple seconds on a low-end phone. Given the companies in questions are building entire data centers to house all their GPUs, an extra 10ms per web-page is not a problem for them. They're going to spend orders of magnitude more compute actually training on the content they scraped, than solving the challenge. It's mostly the inconvenience of adapting to Anubis's JS requirements that held them back for a while, but the PoW difficulty mostly slowed down real users.
- alright2565 1y agoIn part because this particular proof of work is absolutely trivial at scale, with commercial hardware able to do 390TH/s, while your typical phone would only be able to do a million and still have acceptable latency.
- MBCook 1y agoThey also suggest maybe “proof of React” would be better with a link to this rough proof of concept: https://github.com/TecharoHQ/anubis/pull/1038 https://github.com/TecharoHQ/anubis/pull/1038 Could someone explain how this would help stop scrapers? If you’re just running the page JS wouldn’t this run too and let you through?
- fluoridation 1y agoLow-effort scrapers don't run JS, they just fetch static content.
- MBCook 1y agoBut then they couldn’t get past the current Anubis. Sonia the idea it would just be cheaper for clients?
- fluoridation 1y agoThat's the idea. Impose software requirements on the client instead of computational requirements.
- ranger_danger 1y agoThey admitted that this was a 'shitpost'. > how this would help stop scrapers I think anubis bases its purpose on some flawed assumptions: - that most scrapers aren't headless browsers - that they don't have access to millions of different IPs across the world from big/shady proxy companies - that this can help with a real network-level DDoS - that scrapers will give up if the requests become 'too expensive' - that they aren't contributing to warming the planet I'm sure there does exist some older bots that are not smart and don't use headless browsers, but especially with newer tech/AI crawlers/etc., I don't think this is a realistic majority assumption anymore.
- zetanor 1y agoIn practice, any automated work that a real user is willing to wait through will be trivial to accomplish for an organization which scrapes the entire Internet. The real weight behind Anubis is the Javascript gate, not the PoW. It might as well just fetch() into browser.cookies.set().
- jsnell 1y agoAn unavoidable aspect of abuse problems is that there is no perfect solution. As the defender, you’re always making a precision vs. recall tradeoff. After you’ve picked off the low hanging fruit, most of the time the only way to increase recall (i.e. catch more abuse) is by reducing the precision (i.e. having more false positives, where a good user is falsely considered an abuser). In an adversarial engineering domain neither the problems or solutions are static. If by some miracle you have a perfect solution at one point in time, the adversaries will quickly adapt, and your solution stops being perfect. So you’ll mostly be playing the game in this shifting gray area of maybe legit, maybe abusive cases. Since you can’t perfectly classify them (if you could, they wouldn’t be in the gray area), the options are basically to either block all of them, allow all of them, or issue them a challenge that the user must pass to be allowed. The first two options tend to be unacceptable in the gray area, so issuing a challenge that the client must pass is usually the preferred option. A good counter-abuse challenge is something that has at least one of the following properties: 1. It costs more to pass than the economic value that the adversary can extract from the service, but not so much that the legitimate users won’t be willing to pay it. 2. It proves control of a scarce resource without necessarily having to spend that resource, but at least in such a way that the same scarce resource can’t be used to pass unlimited challenges. 3. It produces additional signals that can be used to meaningfully improve the precision/recall tradeoff. And proof of work does none of those. The last two by construction, since compute is about the most fungible resource in the world. The last doesn't work since it's impossible to balance the difficulty factor such that it imposes a cost the attacker would notice but would be acceptable to the defender. If you add 10s to the latency for your worst-case real users (already too long), it'll cost about $0.01/1k solves. That's not a deterrent to any kind of abuse. So proof of work just is a really bad fit for this specific use case. The only advantage is that it is easy to implement, but that's a very short term benefit.
- tptacek 1y agoWithout getting into the alternatives: scraper defense isn't a viable proof of work setting, because there's no asymmetry to exploit. You're imposing exactly the same cost on legit users as you are on scrapers. Economies of scale mean that the marginal cost for your adversary is actually significantly lower than for your real users. What the Anubis POW system is doing right now is exploiting the fact that there's been no need for crawlers to be anything but naive. But the cost to make them sophisticated enough to defeat the POW system is quite low, and when that happens, the POW will just be annoying legit users for no benefit. I don't know if "mistake" is the word I'd use for it. It's not a whole lot of code! It's a reasonable first step to force crawlers to emulate a tiny fraction of a real browser. But as it evolves, it should evolve away from burning compute, because that's playing to lose.
- reisse 1y agoWait, but there is an asymmetry. Legitimate user spends at least a dozen seconds on a page, they don't care about 10ms overhead. For a scraper, however, 10ms overhead can easily be 10x the time it spends on a page overall - the scraper is now ten times slower. However the exact PoW implementation (hash) chosen by Anubis might significantly reduce this asymmetry, because the calculation speed is highly dependent on hardware.
- tptacek 1y agoNo, I don't think this is accurate. You have to look at both the cost and the benefit. If you're an AI scraper, it's literally just "what does the marginal next token of training data cost me" --- the answer is: the same as the marginal next token of content costs a reader. Tavis Ormandy went into more detail on the math here, but it's not great!
- comex 1y agoI don’t understand what you mean. Training an LLM requires orders of magnitude more tokens than any one human will ever read. Perhaps an AI company can amortize across all their users, but it would still represent a substantial cost. And I’m pretty sure the big AI companies don’t rely on abusive scraping (i.e. ignoring robots.txt), so the companies doing the scraping may not have a lot of users anyway.
- DiabloD3 1y agoWait, the Anubis people _didn't know_ 3 core machines were sold for years? AMD was famous for it!
- Sesse__ 1y agoWhat about... single-core machines?
- nerdsniper 1y agoSMT generally caused single-core CPU's to appear as 2 logical cores. I realize Anubis was probably never tested on a true single-core machine. They are actually somewhat difficult to find these days outside of microcontrollers.
- crote 1y agoEven in microcontrollers it is starting to become increasingly rare! We've progressed to a point where sub-$1 hobbyist chips like the RP2040 are multicore these days.
- john-h-k 1y agoThe line of code in the article is `Math.max(nproc / 2, 1)`. So 1 core yields 1 thread. Only CPUs with an odd number of cores, no SMT, and >1 core will hit this bug. Not very common
- jsheard 1y agoIn theory a CPU with SMT could still trigger this bug, because not every core necessarily has to have SMT. Intel made some chips that combined performance cores with SMT and efficiency cores without SMT, so if they had an odd number of E-cores they'd have ended up with an odd number of threads regardless.
- jeffbee 1y agoYou can also just boot linux with maxcpus=5 or any other number. Believing things about the parity of the number of CPUs is just nuts.
- Joker_vD 1y agoI think I actually saw a question on SO way back during the Windows Vista era when some guy asked if Windows supported machines with odd number of cores/processors, and the answer was "well, 1 is an odd number, you know". Another joke from the same era: Having a 2 core processor means that you can now e.g. watch a film at the same time. At the same time with what? At the same time with running Windows Vista!
- creatonez 1y agoSure, but 1 is also a power of 2: 2^0 = 1 So the logic might make sense in people's heads if they never encounter 6 or 12 core CPUs that are common these days.
- MindSpunk 1y agoEven long ago we had the AMD Phenom X3 chips which were 3 cores.
- jsheard 1y agoThe fun thing about those is they were physically quad cores with one core disabled, which may or may not have been defective, so if you were lucky you could unlock it and get a bonus core for free.
- hinkley 1y agoBinning made the world weird.
- close04 1y agoMade it so sweet too. Buying a product that could become so much more (more frequency, more cores, more cache) at no extra cost was magical.
- tomkarho 1y agoGot a 4 core machine that way dirt cheap. Bought (a phenom II BE I think) 2 core cpu which unlocked into a quad core.
- perching_aix 1y agoThe whole Anubis thing is a really interesting predicament for me. I have Chrome on mobile configured as such that JS and cookies are disabled by default, and then I enable them per site based on my judgement. You might be surprised to learn that normally, this actually works fine, and sites are usually better for it. They stop nagging, and load faster. This makes some sense in retrospect, as this is what allows search engine crawlers to do their thing and get that SEO score going. Anubis (and Cloudflare for that matter) force me to temporarily enable JS and cookies at least once however anyways, completely defeating the purpose of my paranoid settings. I basically never bother to, but I do admit it is annoying. It's kind of up there with sites that don't have any content by default, only with JS on (high profile example: AWS docs). At least Cloudflare only spoils the fun every now and then. With Anubis, it's always. It's definitely my fault, but at the same time, I don't feel this is right. Simple static pages now require allowing arbitrary code execution and statefulness. (Although I do recognize that SVGs and fonts also kind of do so anyhow, much to my further annoyance).
- altairprime 1y agoWe have nothing to protect sites against scrapers except to make it more expensive for everyone’s, unless privacy-compromising or authority-trusting methods are on the table. Making you pay time, power, bandwidth, or money to access content does not significantly impede your browsing, so long as the cost is appropriately small. For the user above reporting thirty seconds of maxcpu, that’s excessive for a median normal person (but us hackers are not that). If giving your unique burned-in crypto-attested device ID is acceptable, there’s an entire standard for that, and when your device is found to misbehave, your device can be banned. Nintendo, Sony, Xbox call this a “console ban”; it’s quite effective because it’s stunningly expensive to replace a device. If submitting proof of citizenship through whatever attestation protocol is palatable is okay, the Anubis could simply add the digital ID web standard and let users skip the proof of work in exchange for affirming that they have a valid digital ID. But this only works if your specific identity can be banned, or else AI crawlers will just send a valid anonymized digital ID header. This problem repeats in every suggested outcome: either you make it more difficult for users to access a site, or you require users to waste energy to access a site, or you require identifiable information signed by a dependable third-party authority to be presented such that a ban is possible based on it. IP addresses don’t satisfy this; Apple IDs, trusted-vendor HSM-protected device identifiers, and digital passports do satisfy this. If you have a solution that only presents barriers to excessive use and allows abusive traffic to be revoked without depending on IP address, browser fingerprint, or paid/state credentials, then you can make billions of dollars in twelve months. Ideas welcome! This has been a problem since bots started scraping RSS feeds and republishing them as SEO blogs, and we still don’t have a solution besides Cloudflare and/or CPU-burning interstitials. (ps. I do have a solution for this, but it would require physical builds, be mildly unprofitable over time with no growth potential, and incite governments hostility towards privacy-preserving identity systems. A billionaire philanthropist could build it in a year and completely solve this problem. Sigh.)
- Filligree 1y agoIronically, this sat on the intermission page for a good half-minute while my fans spun up. Then I gave up; it was eating the battery.
- ddulaney 1y agoCan I ask what hardware you’re using? I’ve heard similar things on the internet generally, but I’m on a several-years-old phone and it took under a second. Is the interstitial really that slow on some setups?
- Filligree 1y agoI do a lot of random browsing on an old iPad. Which doesn't have fans, I know, that was short for "it got really hot". I'm not sure what generation it is, but I bought it around a decade ago I think.
- neurostimulant 1y agoOld browsers without crypto support would fall back to pure js sha256 implementation, which I imagine would be slow on an old iPad.
- dmitrygr 1y ago> I guess every assumption that developers have about CPU design is probably wrong. Javascripters, perhaps. Those who work on schedulers, or kernels in general would find this completely normal
- deleted 1y ago[deleted]
- neurostimulant 1y ago> In retrospect implementing the proof of work challenge may have been a mistake and it's likely to be supplanted by things like Proof of React or other methods that have yet to be developed. > ... a challenge method that requires the client to do a single round of SHA-256 hashing deeply nested into a Preact hook in order to prove that the client is running JavaScript. Why a single round? Doing the whole proof of work challenge inside the proof of react would be even more effective, right?
- swiftcoder 1y agoIt wouldn't be any more effective at determining that javascript is executing, and it would use a lot more resources on the client
- stavros 1y agoCan someone explain how this prove that JS is executing? Why couldn't someone simply fake the JS bit and execute the SHA round in their own code?
- Doxin 1y agoYes, but this requires work on the part of the bad guys. As far as I can tell nothing in anubis is exactly hard to get around. The point isn't to be hard to get around. The point is to be annoying enough for people to largely not bother.
- yjftsjthsd-h 1y agoTIL the CPU count is exposed to JS. I guess that's fine? It feels nasty, but it's not really worse than all the other fingerprinting data we expose...
- hinkley 1y agoIt’s also frequently wrong when running in Docker. Some of that is libuv’s fault, some of it is cgroups deciding not to mask off /proc values that are wrong in the cgroup.
- gck1 1y agoAlso fonts you have installed, the type of connection you're using, GPU parameters, keyboard languages on your system and so much more [1] [1] https://abrahamjuliot.github.io/creepjs/ https://abrahamjuliot.github.io/creepjs/
- fuckaj 1y ago[dead]
- Jap2-0 1y agoI might be wrong but I think I heard that Firefox and maybe Safari bin that to a couple common values. (Or maybe that's just in the tracking-prevention mode that Tor uses?)
- daemonologist 1y agoAccording to MDN Safari clamps it to 4 or 8, but Firefox does not: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/hardwareConcurrency https://developer.mozilla.org/en-US/docs/Web/API/Navigator/h... I always found it annoying that CPU information was widely available and precise while memory information was not - it's clamped to 0.25, 0.5, 1, 2, 4 or 8 GB. If you're running something memory-bound in the browser you have to be really conservative to avoid locking up the user's device (or ask them to manually specify how much memory to use). https://developer.mozilla.org/en-US/docs/Web/API/Device_Memory_API https://developer.mozilla.org/en-US/docs/Web/API/Device_Memo...
- hinkley 1y agoSometimes cores are fractional. Particularly thanks to Docker. I’m currently trying to get this fixed in several NodeJS situations.
- ChocolateGod 1y agoThat sounds like something to do with CPU scheduling than actual fractional cores.
- hinkley 1y agoIt does but the example here is figuring out how many workers to spool up for a given machine, and there are many ratios where getting 1 vs .75 would change the correct number. However it’s much worse than that. There’s a bug in libuv that I think is fixed on master but may not have shipped yet, where they fall back to the cgroup cpuset if the returned value is less than 1 (presumably they meant != 0). So if you’re running on a docker or kubernetes host with 8 cores and you try to give one container half a CPU, it will believe it has access to 8, not 0.5 CPUs. And now you’re task switching constantly.
- ChocolateGod 1y agoI have a S24+ and Anubis often runs poorly for me and fails. I tend to frequent tech related sites so browsing on my phone has been miserable the last couple months. I checked the value of navigator.hardwareConcurrency on my phone and it returns 9... I guess that explains it. It looks like setting light performance mode in device optimisations (I don't game on my phone) turns off the S24s sole Cortex-X4.
- fuckaj 1y ago[dead]
- BobbyTables2 1y agoThe only bug is the use of a cursed language such as JavaScript!
- dlcarrier 1y agoAn AMD Ryzen 9 7950x3D has 16 physical cores and 32 logical cores. The diminisshing return for thread counts above cores / 2 is likely due to using the logical core count, not the physical core count, as SMT doesn't improve every type of performance. It's not the fault of Firefox, but an aspect of the CPU design.
- markasoftware 1y agoHow come "let's use some cool cryptography to encrypt error messages" is being considered before "let's use a strongly typed language that even web developers are starting to become fond of" as a way to prevent issues in the future?
- kookamamie 1y agoAssuming core count to be even seems pretty oblivious to me.
- koyote 1y agoIs it just me or does dividing an integer always turn on some alarm bells in my head? I'd immediately look into what happens for odd numbers, rounding, implicit type conversions etc. Or at least that's what I was taught when I first started programming. Also relying on "well we know that X is always Y" is almost always a mistake; maybe not always at first but definitely in the future because X will almost certainly be Y at some point. Defensive coding would catch such issues (with at the very least an Assert somewhere to ensure X is indeed Y before continuing, ensuring that we get a nice error when that assumption proves to be wrong).
- bradley13 1y agoIf I must enable JS for your site to do cryptographic, well, maybe I'll live without your site. Seriously, defend yourself some other way.
- jjuhl 1y agoI wonder why he doesn't just set up a virtual machine with an odd number of vcpu's for testing.
- voidUpdate 1y agos/he/they As covered in TFA, they didn't think about the situation of having an odd number of cores, apart from 1, which they covered with the min
- sim7c00 1y ago>> This could have been prevented on the server side by doing less strict input validation in compliance with Postel's Law. I feel nervous about making such a security-sensitive endpoint more liberal with the inputs it can accept, but it may be fine? I need to consult with a security expert. if its possible to keep it strict, keep it strict. if another solution holds, even if it seems like a band aid, it will be better than relaxing input rules on something like this. I am not specifically expert in these types of systems regarding their security, but this is the general case for such issues if you look at security from a general stance. The trunc, i am not sure how expensive it is as an operation, but that seems like a good solution to me to sanitize the input. That way you can still 'detect' and reject invalid inputs (floats). handling floats is very different than integers (with things like NaN / inf etc.) so if you want to allow floats thats' a whole new area you need to test etc. rather than simply rejectig the invalid input.
- perlgeek 1y agoI remember 3-core CPUs being sold back in the days, which were just 4-core CPUs where one of the cores was defect, and switched off in microcode.
- npn 1y ago> Anubis tries to make sure that it can use as many cores as possible in order to take advantage of your device's CPU as much as it can. Don't do that. Also both the software and its author is now on my blacklist.
- bob1029 1y agoImagine the environmental impact of POW running on everyone's browser all the time globally just to use the internet. What is the point of having these gigawatt class hyperscale datacenters if we are still going to make clients run laps for every request? Performance is the most important feature at some level. If an unauthenticated request from the public internet ties up your web server's CPU for more than a few hundred microseconds, you are eventually going to get screwed no matter how you slice it.
- ChocolateGod 1y ago> Imagine the environmental impact of POW running on everyone's browser all the time globally just to use the internet. Systems that use more electricity for no other reason than use more electricity and raise bills should be illegal imho, as that's what Anubis does and why it blows my mind people think PoW is a good idea. Imagine you bought a TV and there was a device in the TV that did /nothing/ but just use more electricity to persuade agaisnt people having too many TVs in their house.
- ManlyBread 1y agoThe real question here is whether there's a better solution for blocking scrapers and spammers thst clearly do not care about any of these things.
- bob1029 1y agoWriting fast software and using authentication when anonymous requests would be too expensive are excellent solutions. Pretending like these solutions don't exist seems to be the central prerequisite for engaging in much of the related conversation space.
- Avlin67 1y agoso author is not aware of cpu odd cores. ok. he did not use a phenom X4 with only one core unlocked instead of 2 so you end up with a phenom x5