AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
{
"meta": {
"purpose": "Dangerous PHP built-ins mapped to vulnerability class + safe/unsafe recipe. The census enumerates EVERY call site of these in the target so coverage is provable.",
"kinds": {
"call": "function_call_expression — name(...)",
"method": "member/scoped call — $o->m(...) / C::m(...)",
"construct": "language construct — echo/include/require/print/backtick"
}
},
"sinks": [
{"fn":"exec","kind":"call","class":"RCE-command","why":"runs a shell command; tainted arg = command injection","unsafe":"exec($_GET['x'])","safe":"escapeshellarg + fixed binary, or avoid"},
{"fn":"shell_exec","kind":"call","class":"RCE-command","why":"shell command via backtick semantics","unsafe":"shell_exec($cmd)","safe":"escapeshellarg; allow-list"},
{"fn":"system","kind":"call","class":"RCE-command","why":"runs+prints a shell command","unsafe":"system($_POST['c'])","safe":"escapeshellarg; fixed cmd"},
{"fn":"passthru","kind":"call","class":"RCE-command","why":"runs a shell command, raw output","unsafe":"passthru($cmd)","safe":"escapeshellarg"},
{"fn":"proc_open","kind":"call","class":"RCE-command","why":"spawns a process","unsafe":"proc_open($cmd,...)","safe":"array-form args, no shell"},
{"fn":"popen","kind":"call","class":"RCE-command","why":"opens a process pipe via shell","unsafe":"popen($cmd,'r')","safe":"escapeshellarg"},
{"fn":"pcntl_exec","kind":"call","class":"RCE-command","why":"execs a program","unsafe":"pcntl_exec($path,$args)","safe":"validated path"},
{"fn":"eval","kind":"call","class":"RCE-code","why":"executes PHP from a string","unsafe":"eval($code)","safe":"never on untrusted input"},
{"fn":"assert","kind":"call","class":"RCE-code","why":"string arg is eval'd (pre-8.0)","unsafe":"assert($_GET['a'])","safe":"boolean arg only; disable in prod"},
{"fn":"create_function","kind":"call","class":"RCE-code","why":"eval-backed lambda (removed 8.0)","unsafe":"create_function('',$body)","safe":"closures"},
{"fn":"call_user_func","kind":"call","class":"RCE-code","why":"dynamic dispatch; tainted callable = arbitrary call","unsafe":"call_user_func($_GET['f'])","safe":"allow-list of callables"},
{"fn":"call_user_func_array","kind":"call","class":"RCE-code","why":"dynamic dispatch + args","unsafe":"call_user_func_array($_GET['f'],$_GET['a'])","safe":"allow-list"},
{"fn":"unserialize","kind":"call","class":"deserialization","why":"PHP object injection via magic methods (POP chain)","unsafe":"unserialize($_COOKIE['c'])","safe":"json_decode; allowed_classes=false; HMAC-gate"},
{"fn":"include","kind":"construct","class":"LFI-RFI","why":"includes+executes a file path","unsafe":"include $_GET['p']","safe":"fixed/const path; basename+allow-list"},
{"fn":"include_once","kind":"construct","class":"LFI-RFI","why":"same, once","unsafe":"include_once $page","safe":"allow-list"},
{"fn":"require","kind":"construct","class":"LFI-RFI","why":"includes+executes; fatal on miss","unsafe":"require $tpl","safe":"const path"},
{"fn":"require_once","kind":"construct","class":"LFI-RFI","why":"same, once","unsafe":"require_once $mod","safe":"const path"},
{"fn":"file_get_contents","kind":"call","class":"file-read-or-SSRF","why":"reads a path OR a URL (SSRF)","unsafe":"file_get_contents($_GET['u'])","safe":"validate scheme/host; realpath+allow-list"},
{"fn":"readfile","kind":"call","class":"file-read","why":"reads+outputs a file","unsafe":"readfile($_GET['f'])","safe":"basename+allow-list"},
{"fn":"fopen","kind":"call","class":"file-read-or-SSRF","why":"opens a path OR URL","unsafe":"fopen($url,'r')","safe":"scheme allow-list"},
{"fn":"file","kind":"call","class":"file-read","why":"reads a file into an array","unsafe":"file($path)","safe":"allow-list"},
{"fn":"highlight_file","kind":"call","class":"file-read","why":"outputs source of a file","unsafe":"highlight_file($f)","safe":"never on user path"},
{"fn":"show_source","kind":"call","class":"file-read","why":"alias of highlight_file","unsafe":"show_source($f)","safe":"never on user path"},
{"fn":"file_put_contents","kind":"call","class":"file-write","why":"writes/overwrites a path; RCE if .php","unsafe":"file_put_contents($_GET['p'],$d)","safe":"fixed dir; ext allow-list; no user path"},
{"fn":"fwrite","kind":"call","class":"file-write","why":"writes to a handle","unsafe":"fwrite($h,$user)","safe":"validated target"},
{"fn":"move_uploaded_file","kind":"call","class":"file-write","why":"moves an upload; RCE if attacker controls name/ext","unsafe":"move_uploaded_file($t,$_FILES['f']['name'])","safe":"generated name; ext+MIME allow-list; non-exec dir"},
{"fn":"copy","kind":"call","class":"file-write","why":"copies to a path","unsafe":"copy($s,$_GET['d'])","safe":"validated dest"},
{"fn":"rename","kind":"call","class":"file-write","why":"renames/moves","unsafe":"rename($a,$_GET['b'])","safe":"validated"},
{"fn":"unlink","kind":"call","class":"file-delete","why":"deletes a file","unsafe":"unlink($_GET['f'])","safe":"basename+allow-list"},
{"fn":"fsockopen","kind":"call","class":"SSRF","why":"opens a socket to host:port","unsafe":"fsockopen($_GET['h'],$p)","safe":"host/port allow-list; block link-local/private"},
{"fn":"stream_socket_client","kind":"call","class":"SSRF","why":"opens a socket","unsafe":"stream_socket_client($_GET['u'])","safe":"validate"},
{"fn":"curl_exec","kind":"call","class":"SSRF","why":"performs the curl request (URL set via curl_setopt)","unsafe":"curl to $_GET['u']","safe":"scheme/host allow-list; block metadata IP"},
{"fn":"get_headers","kind":"call","class":"SSRF","why":"fetches headers from a URL","unsafe":"get_headers($_GET['u'])","safe":"validate host"},
{"fn":"mysqli_query","kind":"call","class":"SQLi","why":"raw SQL","unsafe":"mysqli_query($c,\"...$id\")","safe":"prepared statements"},
{"fn":"mysql_query","kind":"call","class":"SQLi","why":"raw SQL (legacy)","unsafe":"mysql_query($sql)","safe":"prepared/PDO"},
{"fn":"pg_query","kind":"call","class":"SQLi","why":"raw SQL","unsafe":"pg_query($sql)","safe":"pg_query_params"},
{"fn":"extract","kind":"call","class":"variable-injection","why":"imports array keys into local scope; overwrites vars","unsafe":"extract($_REQUEST)","safe":"EXTR_SKIP; never on request data"},
{"fn":"parse_str","kind":"call","class":"variable-injection","why":"two-arg form imports into scope (1-arg into caller scope pre-8)","unsafe":"parse_str($_SERVER['QUERY_STRING'])","safe":"always pass result array (2-arg)"},
{"fn":"import_request_variables","kind":"call","class":"variable-injection","why":"register_globals emulation","unsafe":"import_request_variables('gpc')","safe":"never"},
{"fn":"simplexml_load_string","kind":"call","class":"XXE","why":"parses XML; entity expansion if NOENT","unsafe":"simplexml_load_string($x,...,LIBXML_NOENT)","safe":"libxml_disable_entity_loader / no NOENT"},
{"fn":"simplexml_load_file","kind":"call","class":"XXE","why":"parses XML file/URL","unsafe":"simplexml_load_file($u)","safe":"disable external entities"},
{"fn":"xml_parse","kind":"call","class":"XXE","why":"SAX parse","unsafe":"xml_parse($p,$user)","safe":"disable entities"},
{"fn":"loadXML","kind":"method","class":"XXE","why":"DOMDocument::loadXML external entities","unsafe":"$dom->loadXML($x,LIBXML_NOENT)","safe":"no NOENT/DTDLOAD"},
{"fn":"load","kind":"method","class":"XXE","why":"DOMDocument::load a path/URL","unsafe":"$dom->load($u)","safe":"disable entities"},
{"fn":"header","kind":"call","class":"header-injection-or-open-redirect","why":"sets a response header; Location = open redirect; CRLF pre-5.1.2","unsafe":"header('Location: '.$_GET['u'])","safe":"validate redirect target; wp_safe_redirect"},
{"fn":"setcookie","kind":"call","class":"header-injection","why":"sets a cookie header","unsafe":"setcookie($n,$_GET['v'])","safe":"sanitize name/value"},
{"fn":"preg_replace","kind":"call","class":"RCE-code-or-ReDoS","why":"/e modifier eval'd replacement (pre-7); user pattern = ReDoS","unsafe":"preg_replace('/x/e',$r,$s)","safe":"preg_replace_callback; fixed pattern"},
{"fn":"echo","kind":"construct","class":"XSS","why":"outputs raw; unescaped request data = reflected XSS","unsafe":"echo $_GET['q']","safe":"esc_html/esc_attr for context"},
{"fn":"print","kind":"construct","class":"XSS","why":"outputs raw","unsafe":"print $user","safe":"escape for context"},
{"fn":"printf","kind":"call","class":"XSS-or-formatstring","why":"raw output; user format string = format bugs","unsafe":"printf($_GET['fmt'])","safe":"fixed format; escape %s args"},
{"fn":"print_r","kind":"call","class":"info-disclosure","why":"dumps structure (with true) or outputs","unsafe":"print_r($config)","safe":"debug only"},
{"fn":"var_dump","kind":"call","class":"info-disclosure","why":"dumps values+types","unsafe":"var_dump($secret)","safe":"debug only"},
{"fn":"phpinfo","kind":"call","class":"info-disclosure","why":"full environment disclosure","unsafe":"phpinfo()","safe":"never in reachable code"},
{"fn":"md5","kind":"call","class":"weak-crypto","why":"fast, broken for passwords/tokens","unsafe":"md5($password)","safe":"password_hash; hash_hmac for tokens"},
{"fn":"sha1","kind":"call","class":"weak-crypto","why":"fast, broken for passwords","unsafe":"sha1($password)","safe":"password_hash"},
{"fn":"mt_rand","kind":"call","class":"weak-random","why":"predictable; unfit for tokens/nonces","unsafe":"mt_rand() as a token","safe":"random_bytes/random_int"},
{"fn":"rand","kind":"call","class":"weak-random","why":"predictable","unsafe":"rand() as a secret","safe":"random_int"},
{"fn":"uniqid","kind":"call","class":"weak-random","why":"time-based, guessable","unsafe":"uniqid() as a token","safe":"random_bytes"}
]
}