AWS Builder Center
The Fraud Nobody Was Looking For

The Fraud Nobody Was Looking For

How Amazon Rekognition, Textract, and SageMaker catch ghost workers, fake wages, and impossible attendance in India's ₹90,000 crore rural employment scheme — and what two real compiler bugs taught me about building it right.

The number that started this

₹90,000 crore. That's roughly what MGNREGA — India's rural employment guarantee scheme — pays rural workers every year. And here's the part that actually stopped me: every single attendance record in that system already carries a geotagged photo and a wage timestamp. Has since 2021. The evidence to catch a huge category of fraud isn't missing. It's just never been cross-referenced.
That's the gap this project sits in. Not "we need more data" — we need to actually look at the data that already exists.

Three patterns, one insight

Manual, sample-based auditing structurally can't catch what this system catches, because the fraud lives in comparisons across thousands of records, not in any single record looked at alone:
  • Recycled identity — the same face indexed under two different job cards. A ghost worker needs a photo, and the cheap way to fake one is reuse a real one.
  • Payment clustering — wages that stay suspiciously uniform across weeks despite variable days worked. Real attendance is noisy. Fabricated attendance often isn't.
  • Geo-impossible attendance — one worker, two sites, twenty-plus kilometers apart, same day.
None of these require new instrumentation. They require someone to actually join the tables.

Why AWS is the engine, not the wrapper

I want to be specific here, because "we used AI" is a sentence that means almost nothing on its own.
Amazon Rekognition does the actual fingerprinting — indexing every attendance photo into a face collection and running similarity search against it on every new upload. This is the load-bearing part of the whole system. No amount of clever prompting an LLM would give you fast, cheap, reliable face-similarity search at this volume; Rekognition is the right narrow tool for a narrow, well-solved problem.
Amazon Textract reads the scanned, often handwritten muster rolls that still exist across rural gram panchayats — generic OCR falls over on tabular handwritten government forms, and Textract's FORMS/TABLES mode is built specifically for that shape of document.
Amazon SageMaker, running a built-in Random Cut Forest model, scores anomalies unsupervised — because no labeled fraud dataset exists for this problem anywhere in the real world. Nobody has ever caught this fraud systematically before, so there's nothing to train a supervised model on. Unsupervised isn't a compromise here. It's the honest fit.
AWS Step Functions orchestrates all of it, per record, with retries and a quarantine path on every single task — which turned out to matter more than I expected, for reasons I'll get to.

The part I actually spent the most time on

Here's what I learned building this, and it's not what I expected going in: the interesting engineering problem wasn't getting Rekognition to find a duplicate face. That's a documented API call. The interesting problem was deciding what happens the moment something breaks.
What happens when the SageMaker endpoint is unreachable mid-batch? I didn't want the answer to be "the pipeline stops and cases silently stop being generated." So the anomaly-scoring Lambda has a fallback: a deterministic, auditable rule-based score that runs when the ML endpoint doesn't respond, explicitly labeled  scoredBy: "fallback_rules"  so nobody downstream mistakes it for the primary model's judgment. I tested that fallback against a synthetic dataset with known, injected fraud — 96.9% precision, 84.7% recall — so it's a credible safety net, not a degraded stub bolted on for show.
And the system never marks a case  confirmed . Only  review  or  cleared . Confirming fraud stays a human auditor's decision, permanently — that's a design choice about accountability, not a missing feature.

Two bugs the compiler found that I couldn't

I want to be honest about something most project write-ups leave out: I built the CDK infrastructure stack in an environment with no internet access, which meant I reviewed every construct call against the AWS CDK API by hand, with no compiler to check my work. When I finally ran  cdk synth  against a real TypeScript compiler, it caught two bugs immediately.
The first: I'd written  HttpUserPoolAuthorizer  as if it lived in the same package as  HttpLambdaIntegration . It doesn't — Cognito authorizers for HTTP APIs live in a separate  aws-apigatewayv2-authorizers  package. One import statement, wrong module, and the compiler caught it instantly.
The second was more interesting: a Step Functions state can only have  .next()  called on it once. I was calling  quarantineTask.next(failState)  inside a loop, once per task being wired up — which threw  State 'SendToQuarantine' already has a next state  on the second iteration. The fix was building that chain once, outside the loop, and reusing the reference. It's the kind of bug that only shows up when you actually construct the state graph, not just type-check it — which is exactly why "I reviewed it carefully" and "the compiler confirmed it" are different claims, and why I said so explicitly rather than pretending my manual review was equivalent to a real build.
Both fixes are two lines each. Finding them mattered more than the two lines themselves.

The part nobody puts in the blog post

Somewhere in the middle of getting this deploy-ready, my AWS account got stuck in payment verification — a common snag for Indian cards hitting AWS's international authorization hold. I spent real hours diagnosing whether it was a card issue, an account issue, or something else entirely, while a hackathon deadline didn't move.
I'm including this because it's true, and because the engineering response to it was the same discipline the project itself is built around: don't let one blocked dependency take down everything downstream. While AWS activation sat in limbo, the CI pipeline kept running — 14 unit tests, an end-to-end precision/recall validation, a  cdk synth  check — all with zero AWS credentials required, all green on GitHub's own runners, independently of my stuck account. The dashboard ran fully functional with synthetic demo data. The evidence that the system works didn't depend on the deploy succeeding on any particular timeline.
That's not a workaround I improvised under pressure. It's the same fallback philosophy the fraud-detection pipeline itself uses, just applied one layer up — to my own build process instead of to Rekognition and SageMaker.

What this actually is, and isn't

This project doesn't claim to be sitting in production, catching real fraud in a real government scheme today. It claims something narrower and more defensible: a correctly engineered, honestly documented, independently verified pipeline, where every claim points at something you can actually check — a test suite that runs in CI without needing my AWS credentials, a validation script that reproduces the same precision and recall numbers on anyone's machine, a fallback matrix documenting every failure mode with the line of code that handles it.
And the pattern generalizes past MGNREGA. Duplicate-identity detection plus payment-anomaly scoring applies anywhere a government pays on photo-verified attendance — PM-AWAS construction sites, Ayushman Bharat provider verification, any wage-guarantee program with a camera and a timestamp. We didn't build a fraud detector for one scheme. We built the primitive.


Repo, deploy guide, and the full fallback matrix are on GitHub — every number in this post is reproducible with one command, not asked to be taken on faith.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article