{"record":{"id":"adf22992f95187ef","repo":"swisskyrepo/PayloadsAllTheThings","slug":"value-not-found","errorCode":null,"errorMessage":"value not found","messagePattern":"value not found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Server Side Request Forgery/Files/ip.py","lineNumber":92,"sourceCode":"def DEC_OVERFLOW_SINGLE(NUMBER):\n\treturn str(int(NUMBER)+256)\n\ndef validIP(address):\n\tparts = address.split(\".\")\n\tif len(parts) != 4:\n\t\treturn False\n\ttry:\n\t\tfor item in parts:\n\t\t\tif not 0 <= int(item) <= 255:\n\t\t\t\treturn False\n\texcept ValueError:\n\t\tprint(\"\\nUsage: python \"+sys.argv[0]+\" IP EXPORT(optional)\\nUsage: python \"+sys.argv[0]+\" 169.254.169.254\\nUsage: python \"+sys.argv[0]+\" 169.254.169.254 export\")\n\t\texit(1)\n\treturn True\n\ndef plain2EnclosedAlphanumericsChar(s0):\n\tif s0 not in EnclosedAlphanumericsData:\n\t\traise Exception('value not found')\n\treturn random.choice(EnclosedAlphanumericsData[s0])\n\ndef convertIP2EnclosedAlphanumericsValue():\n\tIPAddressParts4EnclosedAlphanumerics = arg1.split(\".\")\n\treturnEnclosedAlphanumericsIPAddress = \"\"\n\tfor x in range(0,4):\n\t\tif len(IPAddressParts4EnclosedAlphanumerics[x]) == 3 and (int(IPAddressParts4EnclosedAlphanumerics[x][0]+IPAddressParts4EnclosedAlphanumerics[x][1])) <= 20 and (int(IPAddressParts4EnclosedAlphanumerics[x][0]+IPAddressParts4EnclosedAlphanumerics[x][1]+IPAddressParts4EnclosedAlphanumerics[x][2])) >= 10:\n\t\t\treturnEnclosedAlphanumericsIPAddress = returnEnclosedAlphanumericsIPAddress + plain2EnclosedAlphanumericsChar(IPAddressParts4EnclosedAlphanumerics[x][0]+IPAddressParts4EnclosedAlphanumerics[x][1]);\n\t\t\treturnEnclosedAlphanumericsIPAddress = returnEnclosedAlphanumericsIPAddress + plain2EnclosedAlphanumericsChar(IPAddressParts4EnclosedAlphanumerics[x][2]);\n\t\t\tif x <= 2:\n\t\t\t\treturnEnclosedAlphanumericsIPAddress = returnEnclosedAlphanumericsIPAddress + plain2EnclosedAlphanumericsChar('.');\n\t\telse:\n\t\t\treturnEnclosedAlphanumericsIPAddress = returnEnclosedAlphanumericsIPAddress + plain2EnclosedAlphanumericsChar(IPAddressParts4EnclosedAlphanumerics[x][0]);\n\t\t\tif len(IPAddressParts4EnclosedAlphanumerics[x]) >= 2:\n\t\t\t\treturnEnclosedAlphanumericsIPAddress = returnEnclosedAlphanumericsIPAddress + plain2EnclosedAlphanumericsChar(IPAddressParts4EnclosedAlphanumerics[x][1]);\n\t\t\tif len(IPAddressParts4EnclosedAlphanumerics[x]) == 3:\n\t\t\t\treturnEnclosedAlphanumericsIPAddress = returnEnclosedAlphanumericsIPAddress + plain2EnclosedAlphanumericsChar(IPAddressParts4EnclosedAlphanumerics[x][2]);\n\t\t\tif x <= 2:","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/swisskyrepo/PayloadsAllTheThings/blob/3bff425aca2b020f7334f9d744eed3ca55de8cdf/Server Side Request Forgery/Files/ip.py#L74-L110","documentation":"plain2EnclosedAlphanumericsChar(s0) in ip.py raises Exception('value not found') when s0 is not a key of EnclosedAlphanumericsData — the table that maps plain characters to Unicode Enclosed Alphanumerics (⓪-⑳, circled a-f/x, and fullwidth dots). It is a strict lookup with no fallback: every digit string, letter, or separator passed in must already exist in the table (keys are '0'-'9', '10'-'20', '.', and 'a'-'f','x'). The function backs convertIP2EnclosedAlphanumericsValue(), which rewrites each dot-separated piece of the user-supplied IP argument into circled-character form for SSRF filter-bypass testing.","triggerScenarios":"Passing an IP octet with a leading zero and three digits, e.g. '019' or '009': the len==3 branch computes int(part[0]+part[1]) = 9 (<= 20) and int(full) >= 10, then calls plain2EnclosedAlphanumericsChar('09') — '09' is not a table key (keys have no leading zeros), so it raises. Passing input that is not a dotted-quad of bare digits, e.g. hex octets with letters outside a-f/x ('0x9g...'), uppercase letters, IPv6 colons, or hostname characters; any resulting character or two-digit pair not in EnclosedAlphanumericsData triggers the raise.","commonSituations":"Running the tool with zero-padded octets (some environments/CLI habit zero-pad, like 169.254.169.254 typed as 169.254.0169.254); feeding alternative IP notations (hex/octal/decimal-overflow forms the same script generates) into the enclosed-alphanumerics converter, which only understands digit pairs 10-20 and single digits; copying an IP with stray characters or a hostname where an octet is expected.","solutions":["Normalize the argument before conversion: strip leading zeros from each octet (use str(int(part)) for pure-digit parts) so lookups hit the '0'-'9'/'10'-'20' keys.","Validate the input up front with validIP(arg1) and exit with the usage message instead of letting the table lookup explode mid-conversion.","If you must support other characters, extend EnclosedAlphanumericsData with the missing keys (e.g. '00'-'09' mapped to ⓪①…⑨ compositions) rather than calling the strict lookup.","Replace the raise with a passthrough (return s0) or route through convert(s, error_on_miss=False) from line 114, which already returns unknown input unchanged."],"exampleFix":"# before\ndef plain2EnclosedAlphanumericsChar(s0):\n\tif s0 not in EnclosedAlphanumericsData:\n\t\traise Exception('value not found')\n\treturn random.choice(EnclosedAlphanumericsData[s0])\n\n# after (normalize zero-padded pairs, pass through unknown chars)\ndef plain2EnclosedAlphanumericsChar(s0):\n\tif s0 not in EnclosedAlphanumericsData and s0.isdigit():\n\t\ts0 = str(int(s0))          # '09' -> '9'\n\tif s0 not in EnclosedAlphanumericsData:\n\t\traise Exception('value not found')\n\treturn random.choice(EnclosedAlphanumericsData[s0])","handlingStrategy":"validation","validationCode":"# Normalize + validate the IP argument before enclosed-alphanumerics conversion\nparts = arg1.split('.')\nif len(parts) != 4 or not all(p.isdigit() and 0 <= int(p) <= 255 for p in parts):\n    print('Usage: python %s IP EXPORT(optional) — plain dotted-quad only' % sys.argv[0])\n    exit(1)\nparts = [str(int(p)) for p in parts]          # strip leading zeros: '019' -> '19'\narg1 = '.'.join(parts)","typeGuard":"def encodable_octet(part):\n    \"\"\"True when every lookup key needed for this octet exists in the table.\"\"\"\n    keys = set(EnclosedAlphanumericsData)\n    if (len(part) == 3 and int(part[0] + part[1]) <= 20\n            and int(part) >= 10):\n        return (part[0] + part[1]) in keys and part[2] in keys\n    return all(ch in keys for ch in part)","tryCatchPattern":"try:\n    enc = plain2EnclosedAlphanumericsChar(s0)\nexcept Exception as e:\n    if 'value not found' in str(e):\n        # not representable in Enclosed Alphanumerics — skip this mutation\n        enc = s0\n    else:\n        raise","preventionTips":["Never pass zero-padded octets; normalize with str(int(part)) first.","Restrict input to plain dotted-quad IPv4 (validIP) before calling the enclosed-alphanumerics converter.","Remember the table only covers digits, 10-20, '.', a-f, x — anything else is unrepresentable by design.","Prefer convert(s, error_on_miss=False) at line 114 when a passthrough is acceptable."],"tags":["ssrf","ip-address","unicode","lookup-table","input-validation","python"],"backgroundTag":null,"analyzedSha":"3bff425aca2b020f7334f9d744eed3ca55de8cdf","analyzedAt":"2026-08-14T19:57:51.590Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}