Text is easy to inspect: you can read it, log it and throw it away. Images are heavier, harder to classify and riskier to get wrong. One bad upload can fail App Review, leak a user's location or put illegal material on your servers. This is a practical pipeline for apps where strangers can see each other's pictures.
The pipeline, in order
Order matters more than any single tool. Every image should go through the same stages before anyone else can see it:
- Receive into quarantine: a private location that no other user can read.
- Hash-match against known child sexual abuse material (CSAM). This comes first, before a classifier, a human or any extra copy.
- Classify for nudity, graphic violence and self-harm.
- Decide: allow, flag or block.
- Promote or delete: only allowed (or deliberately held) images move to public storage.
Step 1: known CSAM, by hash
Hash matching compares a fingerprint of the upload with a database of material that has already been identified. Arachnid Shield (from the Canadian Centre for Child Protection) and Microsoft PhotoDNA are both free, but you have to apply for access and approval is not instant, so apply before you need it.
Two limits to understand. A hash match only catches material that is already known, and "no match" does not mean "safe". And a general classifier is not a substitute: some moderation APIs do not score images for minors at all, only text.
If you get a match:
- Block it and never show it. Do not publish it, do not copy it to your normal storage and do not send it around your team.
- Do not open the file. Find it by its content id, take it offline and limit who can access it.
- Report it as the law requires. In the United States, 18 U.S.C. 2258A requires covered providers that learn of apparent CSAM to report it to NCMEC's CyberTipline as soon as reasonably possible, and a report counts as a request to preserve the contents for a year. Other countries have their own authorities and rules. Whether you are a covered provider and how to preserve evidence safely are questions for a lawyer, so check with one for every country where you operate. This article is not legal advice.
- Ban the account and write down what happened and when.
Google Play also asks social and dating apps to publish child safety standards, offer in-app feedback, have a process for reporting CSAM and name a child safety point of contact. Read its Child Safety Standards policy.
Step 2: classify nudity, violence and self-harm
Hosted classifiers return a score from 0 to 1 per category, and you pick thresholds. A reasonable starting policy for a general-audience app:
| Category | Start with | Why |
|---|---|---|
| Sexual content | Block | Rarely ambiguous, and the App Store is strict about it |
| Graphic violence | Flag | News photos, sport and horror art look similar to real harm |
| Self-harm | Flag | A person may need help more than a ban |
Check what each category covers for images. OpenAI's moderation endpoint, for example, scores images only for sexual content, violence and self-harm; hate, harassment and sexual/minors are text-only. A score of 0.0 for an unevaluated category means "not checked", not "clean". Hateful text rendered inside a meme will not trip an image classifier either, so if memes matter to your app, extract the text and moderate it separately.
Start strict where harm is worst, then tune thresholds from your review queue. Every wrongly blocked photo is an annoyed user; every missed one is a report.
When to pre-moderate
Pre-moderation means the image stays hidden until a check says it is fine. Post-moderation publishes first and cleans up after reports. The hash check should always be pre-publish. For the rest, decide by audience:
| Where the image appears | Approach |
|---|---|
| Public feed, profile photos, anything strangers see | Pre-moderate. Hold until the check passes |
| Chats between accepted contacts | Pre-check automatically, then deliver. Users can report and block |
| Private storage only the uploader sees | Hash-check on upload, classify lazily, no review queue |
| Apps with minors, or dating | Pre-moderate everything and keep thresholds strict |
Latency is the usual objection. A classifier call takes seconds, not milliseconds, and a scanner outage or timeout can stretch it. Do not block the upload screen on it: show the post as "processing", run the checks in your backend and set client timeouts longer than the worst case, or a retry will moderate the same image twice.
Blur until reviewed
For borderline results, a middle path beats a binary choice: show the image blurred, with a reveal action for adults who opt in. Two rules keep it honest.
- Blur on the server for pending items. A client-side blur still ships the real pixels, so anyone can pull them from the network response. Serve a blurred derivative until review finishes, then swap in the original.
- Make the state explicit. Store a status per image (pending, active, removed) and let the app read it.
struct PhotoView: View {
let url: URL // blurred derivative while pending
let isPending: Bool
var body: some View {
AsyncImage(url: url) { $0.resizable().scaledToFit() }
placeholder: { ProgressView() }
.overlay(alignment: .bottom) {
if isPending { Text("Under review").padding(6) }
}
}
}
Whatever your threshold, give users a Report button on every image and an instant Block action. Apple's Guideline 1.2 expects both.
Storage and privacy
- Quarantine bucket. Private, random object names, no public listing. Move an image to the public bucket only after it passes.
- Strip metadata. EXIF can contain GPS coordinates and device details. Re-encode uploads and drop it.
- Do not log image bytes or URLs. Log the content id, user id, decision and timestamp instead.
- Short-lived signed URLs for display, so a leaked link stops working.
- Delete on removal. When a moderator removes an image, delete the file and its derivatives, except where a legal duty such as the preservation rule above applies.
- Name your vendors. Moderation APIs and CSAM scanners receive user images, so list them in your privacy policy. Which disclosures apply depends on your country, so ask a lawyer.
One more trap: if you send a URL rather than the file, the scanner and classifier fetch it themselves, and the file at that URL can change afterwards. Send the bytes whenever uploaders control the host.
Images with a drop-in backend
If you would rather not wire this yourself, TrustShip takes an image as image_url or inline image_base64 (PNG, JPEG, GIF or WebP, up to 10 MB decoded) on the same /v1/moderate endpoint it uses for text:
curl -s https://YOUR-MODERATION-HOST/v1/moderate \
-H "Authorization: Bearer $MODERATION_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_url": "https://example.com/upload.jpg", "user_id": "user_42", "content_id": "photo_1001"}'
The behavior, per its documentation:
- Hash check first. With Arachnid Shield or PhotoDNA configured, every image is checked before the moderation provider sees it. A match returns
decision: blockwithreason: csam_match, is never sent on, keeps no bytes or URL, records a safety incident, bans the uploader by default and cannot be appealed. Reporting is your job: it does not contact NCMEC or the police. - No scanner, no images in production. With
ENVIRONMENT=productionit refuses images until a scanner is configured. Without one,csam_scansaysnot_scanned. - Classification returns
allow,flagorblockagainst a per-project policy. The Apple-safe preset blockssexualat 0.5 and flagsviolenceat 0.6 andself_harmat 0.5. With OpenAI, images are scored for those three categories only, andunevaluated_categorieslists the rest. - The queue. A
flaglands in the dashboard queue to approve, remove or ban. Whether to publish or hold while it waits is your app's call, andGET /v1/content/{id}reportspending_review,removedorblockedso your app can blur or hide it. - Privacy. Inline images are decoded in memory and only a SHA-256 of the bytes is stored. An
image_urlis not downloaded by it, but is kept in the audit log, and the vendors that fetch the image should be named in your privacy policy. Always sendcontent_idso you can find the file after a match.
A checklist before you ship
- Apply for hash-matching access now; it can take a while.
- Quarantine every upload and scan before anything else touches it.
- Classify, and know which categories your classifier actually covers for images.
- Choose pre- or post-moderation per surface, not per app.
- Blur on the server while an item is pending.
- Write down your CSAM escalation path, and have a lawyer check it for each country you operate in.
- Strip EXIF, avoid logging content and name your vendors in the privacy policy.
Store policies and laws change. Verify the current Apple and Google texts before you submit, and take legal questions to a lawyer.
Check every image before it goes live
TrustShip puts hash matching, image classification and a review queue behind one endpoint, with a checklist for App Review. Start on the free plan.
Start free