# Grok Imagine API Analysis & Image Provenance System Summary ## Executive Overview This document provides a comprehensive technical breakdown of **xAI Grok's image provenance, lineage tracking, and moderation systems** (specifically regarding `isRootUserUploaded`, `fileSource`, `rRated`, and cryptographic EXIF signatures). The findings are based on 12 target experiments, live browser network payload analysis, raw JSON database inspection (`/rest/assets`), and binary EXIF metadata parsing. --- ## 1. Core Architecture & Provenance Mechanics Grok enforces an **airtight, multi-layered provenance system** to determine whether an image or video generation request is allowed to access restricted/Spicy generation modes (`rRated: true`). ```mermaid flowchart TD A[Image Uploaded to Grok] --> B{EXIF Signature Present?} B -- No (e.g. Raw Photo or Right-Click Save) --> C[Assign: isRootUserUploaded = true] B -- Yes (Official Download File) --> D{Pixels Match Signature & Global Hash?} D -- Pixel Modified / Signature Mismatch --> C D -- Signature Valid & Unmodified --> E{Workspace DB Match & Ancestry Clean?} E -- Ancestor is User Upload --> C E -- Pure Generation Ancestry --> F[Assign: isRootUserUploaded = false] C --> G[Restricted / Non-Spicy Generation Only] F --> H[Unrestricted / Spicy Generations Allowed] ``` ### Key Components 1. **Cryptographic EXIF Signatures:** * Model-generated images are embedded with an EXIF header containing: * `Artist`: The backend asset UUID (e.g., ``). * `Signature`: An RSA-signed cryptographic signature of the pixel data hash. * **Strict Coupling:** The signature is cryptographically bound to the exact pixel bytes. Modifying even a single pixel invalidates the signature verification on upload. 2. **Backend Database Lookup (Pixel Hash & Lineage):** * Upon upload, the backend computes the image's pixel hash and queries its global asset database. * If an image or any of its parent ancestors in the edit tree originated from a user upload, the server taints the lineage, setting `image_edit_is_root_user_uploaded: "true"`. 3. **R-Rated (`rRated`) vs. Provenance (`isRootUserUploaded`):** * **`isRootUserUploaded` (Lineage):** Permanent per tree. Inherited from the root asset. Determines permission to run Spicy/unrestricted edits. * **`r_rated` (Content Classifier):** Dynamically re-evaluated per generation based on visual output content. 4. **CDN Processing & Download Mechanics:** * **Right-Click / Save Image As:** Downloads the web preview rendered by the CDN optimizer. **Strips all EXIF metadata** and renames to `image.jpg`. Uploading this file fails signature checks and defaults to `isRootUserUploaded: true`. * **Official "Download" Button:** Serves the full-quality binary preserving the intact EXIF signature header, named `grok-image-{assetId}.jpg`. Uploading this file preserves signature verification. 5. **Workspace Database Isolation:** * **Main Chat (`grok.com`) vs. Imagine (`grok.com/imagine`):** Asset IDs generated in the Main Chat are stored in the Chat database. When referenced in the Imagine Workspace, the Imagine generator engine cannot find the asset ID in its workspace database and falls back to treating it as an untrusted user upload. --- ## 2. Side-by-Side Metadata Comparison Table Below is the exact raw JSON property comparison from `/rest/assets` across different file categories when uploaded into the Imagine workspace: | JSON Field / Flag | Trusted Pure-Gen Image (`sample_trusted.jpg`) | Signed Grok-Gen Upload (`grok-image-*.jpg`) | Raw User Upload (`photo.jpg` / `sample_user.jpg`) | CDN Strip / Right-Click (`image.jpg`) | | :--- | :--- | :--- | :--- | :--- | | **`fileSource`** | `IMAGINE_SELF_UPLOAD_FILE_SOURCE` | `IMAGINE_SELF_UPLOAD_FILE_SOURCE` | `IMAGINE_SELF_UPLOAD_FILE_SOURCE` | `IMAGINE_SELF_UPLOAD_FILE_SOURCE` | | **`isModelGenerated`** | `false` | `false` | `false` | `false` | | **`isRootAssetCreatedByModel`** | `false` | `false` | `false` | `false` | | **`isRootUserUploaded`** | **`"false"`** *(Trusted)* | **`"false"`** *(Trusted)* | **`"true"`** *(Untrusted)* | **`"true"`** *(Untrusted)* | | **`r_rated`** | `"false"` | `"true"` *(if visual is spicy)* | `"false"` *(or true if visual)* | `"false"` | | **EXIF Signature Status** | Valid & Registered | Valid & Registered | Missing | Stripped by CDN | | **Spicy Edit Access** | **ALLOWED** | **ALLOWED** | **BLOCKED** | **BLOCKED** | --- ## 3. Summary of Verified Experiments | Exp # | Description | Action / Payload | Result | Key Takeaway | | :---: | :--- | :--- | :---: | :--- | | **1** | Stripping EXIF Metadata | Removed EXIF tags from valid signed file (`sample_stripped.jpg`) | **Untrusted** (`true`) | EXIF metadata is required for signature verification on upload. | | **2** | Signature Injection (Mismatch Size) | Injected signature of `1024x1024` into `512x512` image | **Untrusted** (`true`) | Hashes do not match; signature verification fails. | | **3** | Signature Injection (Exact Size) | Resized target to `1024x1024` and injected valid signature | **Untrusted** (`true`) | Pixel hash check fails signature verification. | | **4** | Client Payload Manipulation | Overrode `file_source` to `IMAGINE_GENERATED_FILE_SOURCE` in FormData | **Untrusted** (`true`) | Client request parameters are ignored; server enforces backend DB state. | | **5** | Pipeline Templates | Used `Professional Headshot` template with untrusted upload | **Untrusted** (`true`) | Pre-made workflow pipelines inherit source upload lineage. | | **6** | Video Generation (Animate) | Generated video from an untrusted source asset | **Untrusted** (`true`) | Video generations (`imagine-video-gen`) inherit root lineage. | | **7** | Prompt `@` References | Referenced upload in prompt (e.g. `clothing from @assetId`) | **Untrusted** (`true`) | Prompt references load asset into `inputAssets`, tainting output lineage. | | **8** | Multi-Input Blending | Combined 1 trusted asset + 1 untrusted upload | **Untrusted** (`true`) | If *any* input asset is untrusted, the resulting output is untrusted. | | **9** | Chat Workspace Generation | Generated image in main Chat via uploaded reference | **Signed** | Chat generates valid EXIF signatures, but parent reference links persist. | | **10** | Stripping `Artist` EXIF Tag | Removed `Artist` ID tag while keeping signature block | **Untrusted** (`true`) | Backend uses both pixel hash and EXIF `Artist` ID lookup. | | **11** | Chat Image Re-upload | Uploaded Chat-generated image into Imagine workspace | **Untrusted** (`true`) | Workspace database isolation prevents Imagine from finding Chat IDs. | | **12** | Single-Pixel Modification | Flipped 1 pixel in signed image (`sample_pixel_changed.jpg`) | **Untrusted** (`true`) | Cryptographic signature is strictly coupled to exact pixel data. | --- ## 4. Key Takeaways for Human Engineers & AI Agents 1. **No Client-Side Bypass:** The `isRootUserUploaded` flag cannot be spoofed by modifying FormData, payload parameters, or EXIF metadata on arbitrary images. 2. **Strict Cryptographic Coupling:** You cannot modify, crop, or alter pixels of a signed Grok image without breaking the RSA EXIF signature. 3. **Preserving Trust Status:** To maintain `isRootUserUploaded: "false"` on model-generated assets: * Always use the official **Download** button to retain EXIF signatures. * Avoid right-click saving (which strips EXIF). * Do not mix untrusted uploads into multi-input prompts or `@` references.