How CAPTCHAs work - The Internet's Annoying but Essential Gatekeepers
Published: 2024-06-19 20:23:18


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s55mqdb1xh6v5zej349.png)

If you live on the internet (which is practically everyone these days), you likely come across a CAPTCHA often - those somewhat irritating puzzles asking you to pick traffic lights to prove you’re not a robot. Have you ever wondered how these things work and why they’re needed? Let’s take a deep dive into it. (P.S. There's a bonus section containing bad CAPTCHA examples at the end).

## What's a CAPTCHA

[CAPTCHA](https://en.wikipedia.org/wiki/CAPTCHA?ref=blog.kusho.ai) (which stands for “Completely Automated Public Turing test to tell Computers and Humans Apart”) is a tool used by sites to identify whether an internet user is a human or a bot. 

Around 1997, AltaVista (a primitive search engine of that decade) was having a tough time fixing the high number of auto URL assets that were hampering its website ranking process severely. To solve this issue, the then-chief scientist of AltaVista, Andrei Broder, created an algorithm that later became famous as CAPTCHA.

Because the test is administered by a computer, in contrast to the standard Turing test that is administered by a human, CAPTCHAs are sometimes described as [reverse Turing tests](https://en.wikipedia.org/wiki/Reverse_Turing_test?ref=blog.kusho.ai).

## Why is CAPTCHA needed?
Tl;dr - To make sure some sensitive resource is not exploited using bots

CAPTCHAs are used by any website that wishes to restrict usage by bots. For instance, if you’re running a hotel reservation site, there’s a chance that someone might try to take all the bookings using a bot and legit customers will not be left with any slots. Or you might be running an online poll and want to make sure that votes are not manipulated using bots. CAPTCHA comes in handy in these scenarios making sure only human users can perform some actions blocking access to bot users. 


## How it works
There are different types of CAPTCHAs available in the market these days, each a little different in its workings than the last one. But all of them work on the same principle - ask users to perform some actions that are trivial for a human to do but almost impossible to automate.

Here are some common CAPTCHA flavours and how they work - 

## Classic CAPTCHA (Text-based CAPTCHA)
These are the oldest variants of CAPTCHAs, as the name suggests. Classic CAPTCHAs work by asking a user to identify words. These words are shown in a distorted blurry manner with different fonts and handwriting which makes it very difficult for bots to identify them using OCR but it’s still trivial for human users to decipher.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/06jy46cg0nw0a1vxz038.png)

## ReCAPTCHA
Google came up with a new way to identify human users which doesn’t require users to enter anything. It just asks you to click on a checkbox.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1zn6zs46vkv8ihs0cqgg.png)

How can you figure out if a user is a human or a bot by just looking at a checkbox click, you may wonder. The answer is not in the click but in what happens before you click the checkbox. Google has a [risk analysis engine](https://security.googleblog.com/2014/12/are-you-robot-introducing-no-captcha.html?ref=blog.kusho.ai) that looks at things like how the cursor moved on its way to the checkbox (organic random path/acceleration vs cursor moving in a straight line), which part of the checkbox was clicked (random places, or dead on center every time), browser fingerprint, Google cookies & contents, click location history tied to your fingerprint or account if it detects one, etc. to differentiate between organic and automated clicks. 

## Image-recognition CAPTCHA
For an image-recognition CAPTCHA, users are presented with square images of common objects like bikes, buses, traffic lights, etc. The images may all be from the same large image, or they may each be different. A user has to identify the images that contain certain objects. If their response matches the responses from most other users who have submitted the same test, the answer is considered "correct" and the user passes the test.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90me0o3xnhoeveb85mbk.png)

## Bonus: 5 examples of terrible CAPTCHAs that will make you pull out your hair


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i98bgr852s6135bls847.png)

                 _You need a physics degree to solve CAPTCHAs now?_


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cohzh5ddmykbuxf0k62e.png)
 
                             _Good luck deciphering this_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3v68cteo12pj38zzhd3q.png)

                        _If "you shall not pass" was an image_
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/488fjb9v8kvkuovim1ra.png)

                                     _Speechless_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fpjtsnn9x630g4hn00n.png)

                          _Maybe the robots should take over_