<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Victor Condino on Medium]]></title>
        <description><![CDATA[Stories by Victor Condino on Medium]]></description>
        <link>https://medium.com/@un1tz3r0?source=rss-797db85d74fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*QTjwRYu4gDLA5RkJ</url>
            <title>Stories by Victor Condino on Medium</title>
            <link>https://medium.com/@un1tz3r0?source=rss-797db85d74fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:15:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@un1tz3r0/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[I Accessed 2,000+ Unsecured Ollama Servers]]></title>
            <link>https://medium.com/@un1tz3r0/i-accessed-2-000-unsecured-ollama-servers-4e7c5e524325?source=rss-797db85d74fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e7c5e524325</guid>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Victor Condino]]></dc:creator>
            <pubDate>Sun, 14 Jun 2026 01:43:07 GMT</pubDate>
            <atom:updated>2026-06-14T01:43:07.463Z</atom:updated>
            <content:encoded><![CDATA[<p>There is an unsettling trend within the open-source machine learning community: <strong>security is often an afterthought</strong>. ML is a young field, after all, and frequently the tools and frameworks that power it are so new that they just haven’t existed for long enough to be thoroughly battle-tested. One good example of this is <a href="https://ollama.com/">Ollama</a>.</p><h4>What is Ollama?</h4><p>In case you’re not already familiar, Ollama is a popular, open-source program which allows anyone with a fancy GPU to interact <em>ad-infinitum</em> with powerful large language models (LLMs) running locally, completely offline, and free from subscription fees and privacy concerns that come with the alternative — sending every prompt to a hosted inference platform like the Google Gemini API or Anthropic’s Claude APIs, which charge a miniscule fee per-token, and require users to agree to their conversations being used to train future model upgrades.</p><p>Tokens can add up quickly, and with agentic workflows and agent teams, which have become quite fashionable lately, it’s far too easy to produce traces with millions of tokens from a single overly broad request or one with ill-defined goals or stopping conditions. For many, running models locally is an attractive alternative, despite the slightly lower benchmark scores. I’ve never been a big fan of intelligence tests, though, and it stands to reason that if you can’t accurately assess a person’s overall level of intelligence with a glorified questionnaire, then it would be just as foolhardy to rely too much on similar metrics when applied to thinking machines.</p><p>Ollama owes much of its success to its ease of use; It is easy to install and get up and running, and offers a no-frills text conversational interface, through which the forward-thinking user can converse with a veritable pantheon of freely-available instruction-following AI chat-bot models. It has built-in support for fetching models directly from popular free hosting sites like <a href="https://huggingface.com/">Huggingface</a> and <a href="https://github.com/">GitHub</a>, and it uses interoperability standards adopted by the ML community, like OpenAI’s Inference API, allowing it to be used as a drop-in replacement for the engines powering popular coding tools like Claude Code and automation tools like OpenClaw. It can even run so-called embedding models, which are central to RAG and knowledge-base semantic search applications, where, again, the lack of a roundtrip to a server managed by a third party is an obvious advantage to anyone for whom data security and privacy are a concern (which should be all of us.)</p><h4>How Ollama Works</h4><p>Ollama is designed with a two-part client-server architecture, separating the part which does the heavy lifting of computing the model’s activations and decoding them back into textual responses from the part of the program that provides an interactive user interface which displays the conversation history and allows users to compose and submit their prompts to be processed by the model. These two separate concerns fit nicely into the dual roles of a server and client, respectively.</p><p>We normally think of clients and servers as programs that run on separate machines linked by a network like a LAN or the Internet. It is just as common, though, to have the client and server running on the same computer. The connection never actually flows through a physical network, it just bounces the blocks of information and commands back and forth between the two running programs virtually within the computer’s memory.</p><p>This added complexity might seem unnecessary, but there are numerous advantages to this approach. One server process can provide access to a large resource like a multi-gigabyte language model to multiple running client processes, queueing and processing requests that require exclusive access to the model and GPU serially, ensuring that each client waits its turn. <strong>B</strong>eing separate processes, if a client should crash due to an unrecoverable error, the server’s process is unaffected, allowing other client instances to continue functioning normally. It also simplifies development; programmers can code and test the two programs independently; the only overlap is the format of the messages that they use to communicate the prompts to process and the model’s responses.</p><p>Since Ollama was designed to be used in this local-only configuration, its connections are not authenticated in any way… the server does not require clients to submit credentials or “log in” with a user name and password or secret token of any kind, which would make it more difficult to use with little-to-no practical advantage, since connections from the outside are normally prevented by the computer’s firewall or by a router which connects the devices on your local network to the internet at large, allowing outbound connections but blocking any incoming connection requests. Bottom line: <strong>if you have installed Ollama on your desktop box, rest assured, you are probably not at risk</strong>.</p><h4>When Is Ollama Insecure?</h4><p>There are more advanced scenarios, for instance when renting cloud hosted GPU servers, which is common for AI-powered subscription services that need to be able to flexibly scale capacity in accordance with fluctuations in usage, where Ollama is being used to power some AI feature that is just one piece of a larger application, or for academic and commercial research and development efforts which are running many instances of Ollama at a large scale to process batched prompts. In this case, the Ollama <em>server</em> runs on a networked machine which must be externally reachable from whatever machine the client is running on. This makes things trickier because now Ollama must accept connections from other machines on the network, despite lacking, as noted above, any type of built-in authentication.</p><p>There are ways to mitigate this shortcoming… one could limit connections to the Ollama server socket using a firewall like <em>iptables, </em>and tunnel the connections from the client over a secure protocol which supports connection forwarding, such as <em>ssh.</em> This is generally the route taken when this type of situation arises, but it is not exactly trivial to implement and and even less trivial to get working reliably and seamlessly. The ssh client and server must be installed and configured for automatic, passwordless authentication using private and public key-pairs, and the tunneled connection must be specified on the command line when connecting to the machine running the Ollama server. Timeouts and automatic reconnection must also be configured properly, or the tunneled port is liable to stop working when the connection goes idle or the network connection becomes momentarily unstable.</p><p>All of this is what lead me to believe that there must likely be many unsecured Ollama servers running in the wild. The only thing stopping anyone from connecting to and using these open servers is not knowing their IP addresses.</p><h4>How I Found Hosts Running Ollama</h4><p>You might think that this textbook example of <a href="https://en.wikipedia.org/wiki/Security_through_obscurity">security by obscurity</a> would be the saving grace for anyone who runs an Ollama server on an unprotected machine with internet access, but the internet is a relatively unrestricted medium. There is literally nothing stopping someone from just randomly (or methodically) trying to connect to every single port on every single possible address, to see which ones will accept connections and what the programs listening for those connections have to say to introduce themselves.</p><p>An exhaustive enumeration of every possible permutation of both port and IP address would take a fairly long time to run, even with a very, very fast internet connection. Fortunately, this work has already been done for us, and what’s more we can search the results with a convenient and easy-to-use web interface, through sites like <a href="https://leakix.net/">leakix.net</a>.</p><h4>Port Scanning In Python</h4><p>This is a valuable resource for cybersecurity researchers and curious individuals like myself, so I wrote a python script which uses their API to automate searching and tabulating the results, which you can find <a href="https://gist.github.com/un1tz3r0/8ebd1295aa3a9b85eb65ece1d226b3a8">here</a>, and looks like this:</p><pre>&quot;&quot;&quot;<br>Search the leakix.net database and save the results to a .jsonl file for <br>further processing.<br><br>Requires an API key, get it [here](https://leakix.net/settings/api).<br>Pass it on the command line with the --api-key option argument or put it<br>in a .env file, like this: `LEAKIX_API_KEY=&lt;your-key&gt;`. Their API is free<br>to use (with generous limits), but please don&#39;t abuse it, or you will <br>likely be banned, or worse.<br><br>    - Vic &lt;un1tz3r0@gmail.com&gt; Jun 13, 2026<br>&quot;&quot;&quot;<br><br>import asyncio<br>import json<br>import re<br>import aiofiles<br>import aiohttp<br>import click<br>from aiopathlib import AsyncPath<br>from rich.console import Console<br>from rich.progress import (<br>    Progress,<br>    SpinnerColumn,<br>    TextColumn,<br>    TimeElapsedColumn,<br>)<br><br>LEAKIX_API_KEY = None<br>SEARCH_URL = &quot;https://leakix.net/search&quot;<br><br><br>def load_env(path: str = &quot;.env&quot;) -&gt; dict[str, str]:<br>    &#39;&#39;&#39;<br>    Load environment variables from a .env file.<br><br>    Args:<br>        path (str): Path to the .env file. Defaults to &quot;.env&quot;.<br><br>    Returns:<br>        dict[str, str]: A dictionary containing the environment variables.<br><br>    The .env file should have lines in the format KEY=VALUE. Lines starting<br>    with # are treated as comments and ignored. Values can be optionally<br>    enclosed in single or double quotes. If enclosed in double quotes, escape<br>    sequences will be processed.<br>      &#39;&#39;&#39;<br>    env: dict[str, str] = {}<br>    with open(path, encoding=&quot;utf-8&quot;) as f:<br>        for line in f:<br>            line = line.strip()<br>            if not line or line.startswith(&quot;#&quot;):<br>                continue<br>            if line.startswith(&quot;export &quot;):<br>                line = line[7:].lstrip()<br>            key, sep, value = line.partition(&quot;=&quot;)<br>            if not sep:<br>                continue<br>            key = key.strip()<br>            if not key:<br>                continue<br>            value = value.strip()<br>            if len(value) &gt;= 2 and value[0] == value[-1] and value[0] in (&quot;&#39;&quot;, &#39;&quot;&#39;):<br>                quote = value[0]<br>                value = value[1:-1]<br>                if quote == &#39;&quot;&#39;:<br>                    value = value.encode(&quot;utf-8&quot;).decode(&quot;unicode_escape&quot;)<br>            env[key] = value<br>    return env<br><br># load the api key from the .env file if not set via env var or command line<br>LEAKIX_API_KEY = load_env().get(&quot;LEAKIX_API_KEY&quot;) or LEAKIX_API_KEY<br><br><br>def sanitize_query(q: str) -&gt; str:<br>    slug = re.sub(r&quot;[^A-Za-z0-9._-]+&quot;, &quot;-&quot;, q).strip(&quot;-&quot;)<br>    return slug or &quot;query&quot;<br><br><br>async def fetch_page(<br>    session: aiohttp.ClientSession,<br>    query: str,<br>    page: int,<br>    scope: str,<br>    api_key: str,<br>    console: Console,<br>) -&gt; tuple[list | None, int, str | None]:<br>    headers = {&quot;api-key&quot;: api_key, &quot;accept&quot;: &quot;application/json&quot;}<br>    params = {&quot;q&quot;: query, &quot;scope&quot;: scope, &quot;page&quot;: str(page)}<br>    tries = 0<br><br>    while True:<br>        tries = tries + 1<br>        console.print(<br>            f&quot;[cyan]Fetch URL {SEARCH_URL} with params {params}...&quot;<br>        )<br>        async with session.get(SEARCH_URL, headers=headers, params=params) as resp:<br>            if resp.status == 429:<br>                retry_after_raw = resp.headers.get(&quot;Retry-After&quot;, &quot;5&quot;)<br>                try:<br>                    retry_after = max(1, int(float(retry_after_raw)))<br>                except ValueError:<br>                    retry_after = 5<br>                console.print(<br>                    f&quot;[yellow]429 on page {page}; sleeping {retry_after}s per Retry-After[/]&quot;<br>                )<br>                await asyncio.sleep(retry_after)<br>                continue<br><br>            if resp.status &gt;= 400:<br>                body = await resp.text()<br>                console.print(<br>                    f&quot;[green]{resp.status} on page {page}; got {len(body)} bytes of content&quot;<br>                )<br>                return None, resp.status, body<br><br>            data = await resp.json()<br>            return data, resp.status, None<br><br><br>async def amain(<br>    query: str, scope: str, output: str, api_key: str, max_pages: int | None<br>) -&gt; None:<br>    console = Console()<br>    out_path = AsyncPath(output)<br><br>    console.print(f&quot;[bold cyan]Query:[/]   {query}&quot;)<br>    console.print(f&quot;[bold cyan]Scope:[/]   {scope}&quot;)<br>    console.print(f&quot;[bold cyan]Output:[/]  {output} (append)&quot;)<br>    if max_pages is not None:<br>        console.print(f&quot;[bold cyan]Pages:[/]   cap at {max_pages}&quot;)<br><br>    total_items = 0<br>    page = 0<br>    stop_reason = &quot;unknown&quot;<br><br>    timeout = aiohttp.ClientTimeout(total=60)<br>    async with aiohttp.ClientSession(timeout=timeout) as session:<br>        async with aiofiles.open(out_path, &quot;a&quot;) as f:<br>            with Progress(<br>                SpinnerColumn(),<br>                TextColumn(&quot;[progress.description]{task.description}&quot;),<br>                TimeElapsedColumn(),<br>                console=console,<br>                transient=False,<br>            ) as progress:<br>                task = progress.add_task(&quot;starting...&quot;, total=None)<br>                while True:<br>                    if max_pages is not None and page &gt;= max_pages:<br>                        stop_reason = f&quot;reached --max-pages={max_pages}&quot;<br>                        break<br><br>                    progress.update(<br>                        task,<br>                        description=f&quot;page {page}  |  items so far: {total_items}&quot;,<br>                    )<br><br>                    try:<br>                        data, status, err = await fetch_page(<br>                            session, query, page, scope, api_key, console<br>                        )<br>                    except aiohttp.ClientError as e:<br>                        stop_reason = f&quot;network error on page {page}: {e!r}&quot;<br>                        break<br><br>                    if err is not None:<br>                        snippet = (err or &quot;&quot;).strip()[:500]<br>                        console.print(<br>                            f&quot;[red]HTTP {status} on page {page}[/]\n[red]{snippet}[/]&quot;<br>                        )<br>                        stop_reason = f&quot;HTTP {status} on page {page}&quot;<br>                        break<br><br>                    if not data:<br>                        stop_reason = f&quot;empty page at page {page}&quot;<br>                        break<br><br>                    if not isinstance(data, list):<br>                        stop_reason = f&quot;unexpected response shape on page {page}: {type(data).__name__}&quot;<br>                        console.print(f&quot;[red]{stop_reason}[/]&quot;)<br>                        break<br><br>                    chunk = &quot;&quot;.join(json.dumps(item) + &quot;\n&quot; for item in data)<br>                    await f.write(chunk)<br>                    await f.flush()<br>                    total_items += len(data)<br>                    console.print(f&quot;[green]Got page {page} with {len(data)} items on it.&quot;)<br>                    page += 1<br><br>    console.print()<br>    console.print(f&quot;[bold green]Done.[/] Got {total_items} items across {page} page(s).&quot;)<br>    console.print(f&quot;[dim]Stop reason: {stop_reason}[/]&quot;)<br>    console.print(f&quot;[dim]Output: {output}[/]&quot;)<br><br><br>@click.command()<br>@click.option(<br>    &quot;--query&quot;,<br>    &quot;-q&quot;,<br>    default=&quot;port:11434&quot;,<br>    show_default=True,<br>    help=&quot;LeakIX search query (e.g. &#39;port:11434&#39;).&quot;,<br>)<br>@click.option(<br>    &quot;--scope&quot;,<br>    &quot;-s&quot;,<br>    type=click.Choice([&quot;service&quot;, &quot;leak&quot;]),<br>    default=&quot;service&quot;,<br>    show_default=True,<br>    help=&quot;LeakIX search scope.&quot;,<br>)<br>@click.option(<br>    &quot;--output&quot;,<br>    &quot;-o&quot;,<br>    default=None,<br>    help=&quot;Output JSONL path. Defaults to results-&lt;sanitized-query&gt;.jsonl&quot;,<br>)<br>@click.option(<br>    &quot;--api-key&quot;,<br>    default=LEAKIX_API_KEY,<br>    envvar=&quot;LEAKIX_API_KEY&quot;,<br>    help=&quot;LeakIX API key (or set LEAKIX_API_KEY env var).&quot;,<br>)<br>@click.option(<br>    &quot;--max-pages&quot;, <br>    type=int,<br>    default=None,<br>    help=&quot;Optional cap on number of pages to fetch.&quot;,<br>)<br>def main(<br>    query: str,<br>    scope: str,<br>    output: str | None,<br>    api_key: str,<br>    max_pages: int | None,<br>) -&gt; None:<br>    if output is None:<br>        output = f&quot;results-{sanitize_query(query)}.jsonl&quot;<br>    print(&quot;# Hello from leakix-search!\n&quot;)<br>    asyncio.run(amain(query, scope, output, api_key, max_pages))<br><br><br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p>When we run this script (don’t forget to specify an API key using --<em>api-key</em>), it will show a progress message saying that it is fetching page after page of search results from the <em>leakix.net </em>service search API. It should count up steadily, eventually fetching a total of 500 pages, with 20 results each, for a total of 10,000 results, which it saves as JSON objects, one per line, in a file named <em>results-port-11434.jsonl</em>. Each one looks something like this, pretty-printed for readability:</p><pre>{<br>  &quot;event_type&quot;: &quot;service&quot;,<br>  &quot;event_source&quot;: &quot;HttpPlugin&quot;,<br>  &quot;event_pipeline&quot;: [&quot;tcpid&quot;, &quot;HttpPlugin&quot;],<br>  &quot;event_fingerprint&quot;: &quot;6d1f2e7caae99a60964647f5b908983930bafc8f97400b2397400b23dd52604a&quot;,<br>  &quot;ip&quot;: &quot;4.250.xxx.xxx&quot;,<br>  &quot;host&quot;: &quot;4.250.xxx.xxx&quot;,<br>  &quot;reverse&quot;: &quot;&quot;,<br>  &quot;port&quot;: &quot;11434&quot;,<br>  &quot;mac&quot;: &quot;&quot;,<br>  &quot;vendor&quot;: &quot;&quot;,<br>  &quot;transport&quot;: [&quot;tcp&quot;, &quot;http&quot;],<br>  &quot;protocol&quot;: &quot;http&quot;,<br>  &quot;http&quot;: {<br>    &quot;root&quot;: &quot;/&quot;,<br>    &quot;url&quot;: &quot;/&quot;,<br>    &quot;status&quot;: 200,<br>    &quot;length&quot;: 17,<br>    &quot;header&quot;: {<br>      &quot;content-length&quot;: &quot;17&quot;<br>    },<br>    &quot;title&quot;: &quot;&quot;,<br>    &quot;favicon_hash&quot;: &quot;&quot;<br>  },<br>  &quot;summary&quot;: <br>    &quot;HTTP/1.1 200 OK\n&quot;<br>    &quot;Content-Type: text/plain; charset=utf-8\r\n&quot;<br>    &quot;Date: Mon, 18 May 2026 19:56:51 GMT\r\n&quot;<br>    &quot;Content-Length: 17\r\n&quot;<br>    &quot;Connection: close\r\n&quot;<br>    &quot;\n\n&quot;<br>    &quot;Ollama is running&quot;,<br>  &quot;time&quot;: &quot;2026-05-18T19:56:51.479985914Z&quot;,<br>  /* ... empty fields omitted for brevity ... */<br>  &quot;tags&quot;: [&quot;rescan&quot;], <br>  &quot;geoip&quot;: {<br>    &quot;continent_name&quot;: &quot;Europe&quot;, <br>    &quot;region_iso_code&quot;: &quot;GB-ENG&quot;, <br>    &quot;city_name&quot;: &quot;London&quot;, <br>    &quot;country_iso_code&quot;: &quot;GB&quot;, <br>    &quot;country_name&quot;: &quot;United Kingdom&quot;, <br>    &quot;region_name&quot;: &quot;England&quot;, <br>    &quot;location&quot;: {<br>      &quot;lat&quot;: 5x.xxxx, <br>      &quot;lon&quot;: -0.xxxx<br>    }<br>  },<br>  &quot;network&quot;: {<br>    &quot;organization_name&quot;: &quot;Microsoft Corporation&quot;, <br>    &quot;asn&quot;: 8075,<br>    &quot;network&quot;: &quot;4.224.0.0/11&quot;<br>  }<br>}</pre><p>That’s quite a few interesting-looking details… each search result has a wealth of information about a computer somewhere on the internet which had a service listening on port 11434 at the time that <em>leakix.net </em>last ran a port-scan against it. It even collects the HTTP server response, which in this case ends with “Ollama is running”, a pretty good indication that we have indeed found what we are looking for. And as we can see, there are quite a few, and now we know their IP addresses.</p><h4>Surveying The Servers</h4><p>So now that we have our list of potentially unsecured Ollama servers IP addresses, of course we would like to know more about them. Which of them are still up and running? Whether or not they are really running Ollama or if there’s some other service listening on the same obscure, high-numbered port?</p><p>Ollama clients have various <em>subcommands</em> that translate into different requests which are forwarded to the server, printing the server’s reply to the client command’s standard output before exiting. We want a command that doesn’t make any changes on the server; just in case the server is in use by an authorized user, we should try to avoid doing anything that might disrupt whatever they are doing.</p><p>The <em>list </em>and <em>ps </em>subcommands<em> </em>(see <em>ollama --help </em>for a full list with brief descriptions of each) are fairly safe, as they both just report back information about the server, without changing anything . The first, <em>list, </em>will tell us about the <strong>models</strong> that are downloaded and cached, meaning they are available to load into memory and run. It returns a full list of all the <em>model names</em> that have been fetched and are stored on the server, along with some details about each one like the family, or architecture, that it is based on, what type of quantization is used to compress its weights (allowing larger models to run with a minimal loss of fidelity on GPUs with less on-board RAM) and the number of parameters (the effective size of the model, more generally means more capable, smarter) and how many tokens fit in its context window (which effectively limits the amount of conversation history which the model can reliably handle).</p><p>The <em>ps</em> subcommand tells us which of the available models is currently loaded into the GPU’s on-board RAM, making it ready to process prompts with minimal latency. This is whatever model is currently in use, or was last used by whoever is operating the server.</p><p>So, we want to go down the list of servers that were found with our search, and for each one, try connecting as an Ollama client and then run these two read-only commands, tabulating whatever responses we get for each of them. <strong>This is definitely another job for a python script.</strong> Here is the one I wrote, available <a href="https://gist.github.com/un1tz3r0/3e0025e70c1c3f1657a4ff34e78757fa">here</a> and reproduced below:</p><pre>&quot;&quot;&quot;<br>This script reads the output file written by <br>[this script](https://gist.github.com/un1tz3r0/8ebd1295aa3a9b85eb65ece1d226b3a8),<br>and then attempts to connect and query the models available on each host found <br>by the `leakix.net` service port search that it does. It writes the results to <br>a file `scan_results.jsonl` in the current directory for further processing.<br><br>**DISCLAIMER**<br><br>Depending on where you live, this may be illegal, or is at least frowned upon <br>by many. It is therefore my stern reccomendation that under no circumstances <br>should you or anyone else actually run this code or any variation or derivative<br>of it, not for any purpose whatsoever, without checking the laws which govern<br>your geographical region. Running it also will almost certainly constitute a <br>serious violation of the terms of service upon which your ISP conditionally <br>provides you internet access.<br><br>I, the author &lt;un1tz3r0@gmail.com&gt;, disclaim any responsibility and liability <br>for any damages or injury to property, persons or pride and reputation as a <br>direct or indirect result of the use of this code. This code is made available<br>for informative and entertainment purposes only and without any warranty or <br>guarantee of fitness for any purpose safe or free from back-doors, spyware and <br>rootkits that provide remote access to your network to the CIA. This code may <br>cause your toilet to keep filling unless you jiggle the handle.<br><br>   - VMC &lt;un1tz3r0@gmail.com&gt;<br>     June 8th, 2026<br>&quot;&quot;&quot;<br><br>import asyncio<br>import json<br>import time<br>from datetime import datetime, timezone<br>from pathlib import Path<br>import aiofiles<br>import aiohttp<br>import click<br>from rich.console import Group<br>from rich.live import Live<br>from rich.progress import (<br>    BarColumn,<br>    MofNCompleteColumn,<br>    Progress,<br>    SpinnerColumn,<br>    TextColumn,<br>    TimeElapsedColumn,<br>    TimeRemainingColumn,<br>)<br>from rich.table import Table<br><br><br>class WorkerState:<br>    __slots__ = (&quot;wid&quot;, &quot;host&quot;, &quot;stage&quot;, &quot;started&quot;, &quot;last_result&quot;)<br><br>    def __init__(self, wid: int) -&gt; None:<br>        self.wid = wid<br>        self.host = &quot;&quot;<br>        self.stage = &quot;idle&quot;<br>        self.started: float | None = None<br>        self.last_result = &quot;&quot;<br><br>    def begin(self, host: str) -&gt; None:<br>        self.host = host<br>        self.stage = &quot;connect&quot;<br>        self.started = time.monotonic()<br><br>    def to(self, stage: str) -&gt; None:<br>        self.stage = stage<br><br>    def finish(self, summary: str) -&gt; None:<br>        self.stage = &quot;idle&quot;<br>        self.host = &quot;&quot;<br>        self.started = None<br>        self.last_result = summary<br><br><br>async def call_endpoint(<br>    session: aiohttp.ClientSession,<br>    url: str,<br>    timeout: aiohttp.ClientTimeout,<br>) -&gt; tuple[object | None, int]:<br>    t0 = time.monotonic()<br>    result: object | None = None<br>    try:<br>        async with session.get(url, timeout=timeout) as r:<br>            if r.status == 200:<br>                try:<br>                    result = await r.json(content_type=None)<br>                except (json.JSONDecodeError, aiohttp.ContentTypeError, UnicodeDecodeError):<br>                    result = None<br>    except (aiohttp.ClientError, asyncio.TimeoutError, OSError):<br>        result = None<br>    elapsed_ms = int((time.monotonic() - t0) * 1000)<br>    return result, elapsed_ms<br><br><br>async def post_endpoint(<br>    session: aiohttp.ClientSession,<br>    url: str,<br>    payload: dict,<br>    timeout: aiohttp.ClientTimeout,<br>) -&gt; tuple[object | None, int]:<br>    t0 = time.monotonic()<br>    result: object | None = None<br>    try:<br>        async with session.post(url, json=payload, timeout=timeout) as r:<br>            if r.status == 200:<br>                try:<br>                    result = await r.json(content_type=None)<br>                except (json.JSONDecodeError, aiohttp.ContentTypeError, UnicodeDecodeError):<br>                    result = None<br>    except (aiohttp.ClientError, asyncio.TimeoutError, OSError):<br>        result = None<br>    elapsed_ms = int((time.monotonic() - t0) * 1000)<br>    return result, elapsed_ms<br><br><br>def extract_model_names(result: object | None) -&gt; list[str]:<br>    if not isinstance(result, dict):<br>        return []<br>    models = result.get(&quot;models&quot;)<br>    if not isinstance(models, list):<br>        return []<br>    names: list[str] = []<br>    for m in models:<br>        if not isinstance(m, dict):<br>            continue<br>        name = m.get(&quot;name&quot;) or m.get(&quot;model&quot;)<br>        if isinstance(name, str) and name:<br>            names.append(name)<br>    return names<br><br><br>async def probe_host(<br>    host: str,<br>    port: int,<br>    connect_timeout: float,<br>    read_timeout: float,<br>    state: WorkerState,<br>    seen_models: dict,<br>    models_lock: asyncio.Lock,<br>) -&gt; dict:<br>    base = f&quot;http://{host}:{port}&quot;<br>    timeout = aiohttp.ClientTimeout(<br>        total=None,<br>        sock_connect=connect_timeout,<br>        sock_read=read_timeout,<br>    )<br><br>    list_result: object | None = None<br>    list_time: int | None = None<br>    ps_result: object | None = None<br>    ps_time: int | None = None<br><br>    connector = aiohttp.TCPConnector(limit=2, force_close=True)<br>    try:<br>        async with aiohttp.ClientSession(connector=connector) as session:<br>            state.to(&quot;list&quot;)<br>            list_result, list_time = await call_endpoint(<br>                session, f&quot;{base}/api/tags&quot;, timeout<br>            )<br><br>            state.to(&quot;ps&quot;)<br>            ps_result, ps_time = await call_endpoint(<br>                session, f&quot;{base}/api/ps&quot;, timeout<br>            )<br><br>            list_names = extract_model_names(list_result)<br>            ps_names = extract_model_names(ps_result)<br><br>            needs_show: list[str] = []<br>            if list_names or ps_names:<br>                async with models_lock:<br>                    for name in list_names:<br>                        entry = seen_models.get(name)<br>                        if entry is None:<br>                            entry = [set(), set(), None]<br>                            seen_models[name] = entry<br>                        entry[0].add(host)<br>                        if entry[2] is None and name not in needs_show:<br>                            needs_show.append(name)<br>                    for name in ps_names:<br>                        entry = seen_models.get(name)<br>                        if entry is None:<br>                            entry = [set(), set(), None]<br>                            seen_models[name] = entry<br>                        entry[1].add(host)<br>                        if entry[2] is None and name not in needs_show:<br>                            needs_show.append(name)<br><br>            if needs_show:<br>                state.to(&quot;show&quot;)<br>                for name in needs_show:<br>                    info, _ = await post_endpoint(<br>                        session, f&quot;{base}/api/show&quot;, {&quot;model&quot;: name}, timeout<br>                    )<br>                    if not isinstance(info, dict):<br>                        continue<br>                    async with models_lock:<br>                        entry = seen_models.get(name)<br>                        if entry is not None and entry[2] is None:<br>                            entry[2] = info<br>    except Exception:<br>        pass<br><br>    return {<br>        &quot;host&quot;: host,<br>        &quot;list_result&quot;: list_result,<br>        &quot;list_time&quot;: list_time,<br>        &quot;ps_result&quot;: ps_result,<br>        &quot;ps_time&quot;: ps_time,<br>        &quot;timestamp&quot;: datetime.now(timezone.utc).isoformat(),<br>    }<br><br><br>async def worker(<br>    state: WorkerState,<br>    queue: &quot;asyncio.Queue[str | None]&quot;,<br>    write_q: &quot;asyncio.Queue[dict | None]&quot;,<br>    counters: dict,<br>    port: int,<br>    connect_timeout: float,<br>    read_timeout: float,<br>    seen_models: dict,<br>    models_lock: asyncio.Lock,<br>) -&gt; None:<br>    while True:<br>        host = await queue.get()<br>        if host is None:<br>            queue.task_done()<br>            return<br>        state.begin(host)<br>        try:<br>            result = await probe_host(<br>                host, port, connect_timeout, read_timeout, state,<br>                seen_models, models_lock,<br>            )<br>            if result[&quot;list_result&quot;] is not None or result[&quot;ps_result&quot;] is not None:<br>                counters[&quot;ok&quot;] += 1<br>                state.finish(f&quot;ok    {host}&quot;)<br>            else:<br>                counters[&quot;fail&quot;] += 1<br>                state.finish(f&quot;fail  {host}&quot;)<br>        except Exception as e:<br>            counters[&quot;fail&quot;] += 1<br>            state.finish(f&quot;err   {host}: {type(e).__name__}&quot;)<br>            result = {<br>                &quot;host&quot;: host,<br>                &quot;list_result&quot;: None,<br>                &quot;list_time&quot;: None,<br>                &quot;ps_result&quot;: None,<br>                &quot;ps_time&quot;: None,<br>                &quot;timestamp&quot;: datetime.now(timezone.utc).isoformat(),<br>            }<br>        await write_q.put(result)<br>        counters[&quot;done&quot;] += 1<br>        queue.task_done()<br><br><br>async def writer_task(<br>    write_q: &quot;asyncio.Queue[dict | None]&quot;, path: Path<br>) -&gt; None:<br>    async with aiofiles.open(path, &quot;a&quot;) as f:<br>        while True:<br>            item = await write_q.get()<br>            if item is None:<br>                write_q.task_done()<br>                return<br>            await f.write(json.dumps(item, ensure_ascii=False) + &quot;\n&quot;)<br>            await f.flush()<br>            write_q.task_done()<br><br><br>async def dump_models(<br>    seen_models: dict,<br>    models_lock: asyncio.Lock,<br>    path: Path,<br>    backup: Path,<br>) -&gt; None:<br>    async with models_lock:<br>        snapshot = [<br>            (name, sorted(entry[0]), sorted(entry[1]), entry[2])<br>            for name, entry in seen_models.items()<br>        ]<br>    if not snapshot:<br>        return<br>    lines = [<br>        json.dumps(<br>            [name, [list_servers, ps_servers, info]],<br>            ensure_ascii=False,<br>        )<br>        for name, list_servers, ps_servers, info in snapshot<br>    ]<br>    if backup.exists():<br>        backup.unlink()<br>    if path.exists():<br>        path.rename(backup)<br>    async with aiofiles.open(path, &quot;w&quot;) as f:<br>        await f.write(&quot;\n&quot;.join(lines) + &quot;\n&quot;)<br>        await f.flush()<br>    if backup.exists():<br>        backup.unlink()<br><br><br>async def models_dumper(<br>    seen_models: dict,<br>    models_lock: asyncio.Lock,<br>    path: Path,<br>    interval: float,<br>    stop_event: asyncio.Event,<br>) -&gt; None:<br>    backup = Path(str(path) + &quot;.bak&quot;)<br>    next_dump = time.monotonic() + interval<br>    while not stop_event.is_set():<br>        wait = max(0.0, next_dump - time.monotonic())<br>        try:<br>            await asyncio.wait_for(stop_event.wait(), timeout=wait)<br>        except asyncio.TimeoutError:<br>            pass<br>        if stop_event.is_set():<br>            break<br>        await dump_models(seen_models, models_lock, path, backup)<br>        next_dump = time.monotonic() + interval<br>    await dump_models(seen_models, models_lock, path, backup)<br><br><br>def render(<br>    progress: Progress,<br>    workers: list[WorkerState],<br>    counters: dict,<br>) -&gt; Group:<br>    table = Table(expand=True, show_edge=False, pad_edge=False)<br>    table.add_column(&quot;W&quot;, justify=&quot;right&quot;, style=&quot;cyan&quot;, no_wrap=True, width=4)<br>    table.add_column(&quot;Host&quot;, no_wrap=True, width=22)<br>    table.add_column(&quot;Stage&quot;, no_wrap=True, width=8)<br>    table.add_column(&quot;Elapsed&quot;, justify=&quot;right&quot;, no_wrap=True, width=8)<br>    table.add_column(&quot;Last&quot;, overflow=&quot;ellipsis&quot;, no_wrap=True)<br><br>    now = time.monotonic()<br>    stage_style = {<br>        &quot;idle&quot;: &quot;dim&quot;,<br>        &quot;connect&quot;: &quot;yellow&quot;,<br>        &quot;list&quot;: &quot;blue&quot;,<br>        &quot;ps&quot;: &quot;magenta&quot;,<br>        &quot;show&quot;: &quot;cyan&quot;,<br>    }<br>    for w in workers:<br>        elapsed = f&quot;{(now - w.started):.2f}s&quot; if w.started else &quot;-&quot;<br>        color = stage_style.get(w.stage, &quot;&quot;)<br>        stage_cell = f&quot;[{color}]{w.stage}[/]&quot; if color else w.stage<br>        last_color = &quot;&quot;<br>        if w.last_result.startswith(&quot;ok&quot;):<br>            last_color = &quot;green&quot;<br>        elif w.last_result.startswith((&quot;fail&quot;, &quot;err&quot;)):<br>            last_color = &quot;red&quot;<br>        last_cell = (<br>            f&quot;[{last_color}]{w.last_result}[/]&quot; if last_color else w.last_result<br>        )<br>        table.add_row(str(w.wid), w.host or &quot;-&quot;, stage_cell, elapsed, last_cell)<br><br>    summary = (<br>        f&quot;[green]ok:[/] {counters[&#39;ok&#39;]}  &quot;<br>        f&quot;[red]fail:[/] {counters[&#39;fail&#39;]}  &quot;<br>        f&quot;[cyan]done:[/] {counters[&#39;done&#39;]}/{counters[&#39;total&#39;]}&quot;<br>    )<br>    return Group(progress, summary, table)<br><br><br>async def refresher(<br>    live: Live, interval: float, render_fn<br>) -&gt; None:<br>    try:<br>        while True:<br>            live.update(render_fn(), refresh=True)<br>            await asyncio.sleep(interval)<br>    except asyncio.CancelledError:<br>        pass<br><br><br>async def amain(<br>    input_path: Path,<br>    output_path: Path,<br>    models_output_path: Path,<br>    concurrency: int,<br>    connect_timeout: float,<br>    read_timeout: float,<br>    port: int,<br>    update_interval: float,<br>    dump_interval: float,<br>) -&gt; None:<br>    hosts: list[str] = []<br>    seen: set[str] = set()<br>    for line in input_path.read_text().splitlines():<br>        line = line.strip()<br>        if not line or line.startswith(&quot;#&quot;):<br>            continue<br>        try:<br>            obj = json.loads(line)<br>        except json.JSONDecodeError:<br>            click.echo(f&quot;skipping non-JSON line: {line[:80]}&quot;, err=True)<br>            continue<br>        ip = obj.get(&quot;ip&quot;) if isinstance(obj, dict) else None<br>        if not ip or ip in seen:<br>            continue<br>        seen.add(ip)<br>        hosts.append(ip)<br>    if not hosts:<br>        click.echo(&quot;no hosts to scan&quot;, err=True)<br>        return<br><br>    queue: asyncio.Queue[str | None] = asyncio.Queue()<br>    for h in hosts:<br>        queue.put_nowait(h)<br>    for _ in range(concurrency):<br>        queue.put_nowait(None)<br><br>    write_q: asyncio.Queue[dict | None] = asyncio.Queue()<br>    counters = {&quot;ok&quot;: 0, &quot;fail&quot;: 0, &quot;done&quot;: 0, &quot;total&quot;: len(hosts)}<br>    workers = [WorkerState(i) for i in range(concurrency)]<br>    seen_models: dict = {}<br>    models_lock = asyncio.Lock()<br>    stop_event = asyncio.Event()<br><br>    progress = Progress(<br>        SpinnerColumn(),<br>        TextColumn(&quot;[progress.description]{task.description}&quot;),<br>        BarColumn(),<br>        MofNCompleteColumn(),<br>        TextColumn(&quot;•&quot;),<br>        TimeElapsedColumn(),<br>        TextColumn(&quot;eta&quot;),<br>        TimeRemainingColumn(),<br>        expand=True,<br>    )<br>    task_id = progress.add_task(&quot;scanning&quot;, total=len(hosts))<br><br>    def render_fn() -&gt; Group:<br>        progress.update(task_id, completed=counters[&quot;done&quot;])<br>        return render(progress, workers, counters)<br><br>    with Live(render_fn(), auto_refresh=False) as live:<br>        ref = asyncio.create_task(refresher(live, update_interval, render_fn))<br>        writer = asyncio.create_task(writer_task(write_q, output_path))<br>        dumper = asyncio.create_task(<br>            models_dumper(<br>                seen_models, models_lock, models_output_path,<br>                dump_interval, stop_event,<br>            )<br>        )<br>        worker_tasks = [<br>            asyncio.create_task(<br>                worker(<br>                    workers[i],<br>                    queue,<br>                    write_q,<br>                    counters,<br>                    port,<br>                    connect_timeout,<br>                    read_timeout,<br>                    seen_models,<br>                    models_lock,<br>                )<br>            )<br>            for i in range(concurrency)<br>        ]<br>        try:<br>            await asyncio.gather(*worker_tasks)<br>        finally:<br>            stop_event.set()<br>            await dumper<br>            await write_q.put(None)<br>            await writer<br>            ref.cancel()<br>            try:<br>                await ref<br>            except asyncio.CancelledError:<br>                pass<br>            live.update(render_fn(), refresh=True)<br><br>    click.echo(<br>        f&quot;\nDone. ok={counters[&#39;ok&#39;]} fail={counters[&#39;fail&#39;]} &quot;<br>        f&quot;total={counters[&#39;total&#39;]}  output={output_path}  &quot;<br>        f&quot;models={len(seen_models)} -&gt; {models_output_path}&quot;<br>    )<br><br><br>@click.command()<br>@click.option(<br>    &quot;--input&quot;,<br>    &quot;-i&quot;,<br>    &quot;input_file&quot;,<br>    type=click.Path(exists=True, dir_okay=False, path_type=Path),<br>    default=Path(&quot;results-port-11434.jsonl&quot;),<br>    show_default=True,<br>    help=&quot;Input JSONL file (from 1_search.py); the &#39;ip&#39; field is extracted from each line.&quot;,<br>)<br>@click.option(<br>    &quot;--output&quot;,<br>    &quot;-o&quot;,<br>    &quot;output_file&quot;,<br>    type=click.Path(dir_okay=False, path_type=Path),<br>    default=Path(&quot;connect-results.jsonl&quot;),<br>    show_default=True,<br>    help=&quot;Output JSONL file (appended).&quot;,<br>)<br>@click.option(<br>    &quot;--concurrency&quot;,<br>    &quot;-c&quot;,<br>    type=int,<br>    default=50,<br>    show_default=True,<br>    help=&quot;Number of concurrent worker tasks.&quot;,<br>)<br>@click.option(<br>    &quot;--connect-timeout&quot;,<br>    type=float,<br>    default=5.0,<br>    show_default=True,<br>    help=&quot;Per-request TCP connect timeout in seconds.&quot;,<br>)<br>@click.option(<br>    &quot;--read-timeout&quot;,<br>    type=float,<br>    default=10.0,<br>    show_default=True,<br>    help=&quot;Per-request socket read timeout in seconds.&quot;,<br>)<br>@click.option(<br>    &quot;--port&quot;,<br>    &quot;-p&quot;,<br>    type=int,<br>    default=11434,<br>    show_default=True,<br>    help=&quot;TCP port to connect on.&quot;,<br>)<br>@click.option(<br>    &quot;--update-interval&quot;,<br>    type=float,<br>    default=0.5,<br>    show_default=True,<br>    help=&quot;Status display refresh interval in seconds.&quot;,<br>)<br>@click.option(<br>    &quot;--models-output&quot;,<br>    &quot;models_output_file&quot;,<br>    type=click.Path(dir_okay=False, path_type=Path),<br>    default=Path(&quot;scan-results.jsonl&quot;),<br>    show_default=True,<br>    help=&quot;Per-model aggregation output (overwritten each dump).&quot;,<br>)<br>@click.option(<br>    &quot;--dump-interval&quot;,<br>    type=float,<br>    default=5.0,<br>    show_default=True,<br>    help=&quot;How often (seconds) to rewrite the models-output file.&quot;,<br>)<br>def main(<br>    input_file: Path,<br>    output_file: Path,<br>    concurrency: int,<br>    connect_timeout: float,<br>    read_timeout: float,<br>    port: int,<br>    update_interval: float,<br>    models_output_file: Path,<br>    dump_interval: float,<br>) -&gt; None:<br>    asyncio.run(<br>        amain(<br>            input_file,<br>            output_file,<br>            models_output_file,<br>            concurrency,<br>            connect_timeout,<br>            read_timeout,<br>            port,<br>            update_interval,<br>            dump_interval,<br>        )<br>    )<br><br><br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p>The script above reads the <em>results-port-11434.jsonl</em> file created by the first script, and queues up each unique IP address returned by the search to be processed by the next available worker in a pool of concurrently running worker tasks, which take addresses, one at a time, and run both Ollama commands against them, tabulating the results and writing them to a pair of output files, <em>connect-results.jsonl</em> and <em>scan-results.jsonl</em>.</p><p>You may be asking yourself, “Why all the extra complexity? Why not just process them sequentially with a single, simple <em>for </em>loop?”</p><p>The answer is, of course, performance. The majority of the time it takes to run our commands and get the servers’ responses is actually spent doing nothing, waiting to recieve an answer from the server. While we are waiting for one server’s answer, we could just as easily be sending a request to another, so long as we keep track of which socket is which so that we know what IP address corresponds to each response, we can actually manage quite a few connections simultaneously like this at once without coming close to eating up our Internet connection’s available bandwidth.</p><h4>Parallel Pool Party</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*r2pNqCl7Smo5DgXNYqXqEA.png" /><figcaption>Dashboard output of the Ollama scanning script in progress</figcaption></figure><p>While our script is running, the workers activity and states are shown in the terminal as a tabulated list of all of the workers and which address each one is currently in the process of attempting to interrogate. The network operations performed by the workers are configured with timeouts so that a poor connection or a crashed or misbehaving server on the other end of the workers’ connections will not occupy the worker that is waiting for it forever, to ensure that we never encounter a situation where all of the workers are stuck waiting forever for operations that cannot be completed. The script coordinates the workers and when it determines that all of the potential servers have been tried, it signals them to stop awaiting additional jobs and exit before the script itself ends.</p><p>The results of our Ollama client scan are collated and saved in a pair of files, <em>scan_results.jsonl</em> and <em>connect_results.jsonl, </em>that are intended to be read and processed offline by a pair of scripts, called <em>figures.py</em> and <em>report.py</em> which will tally the results and emit a handful of interesting statistics for us, rendered as charts and graphs and an interactive HTML report for browsing and sorting detailed tables of the results and statistics. They are available along with the first two scripts here: <a href="https://github.com/un1tz3r0/leakix-ollama-search">https://github.com/un1tz3r0/leakix-ollama-search</a>.</p><h4>What Did We Learn?</h4><p>Here are a few interesting statistics which the above two scripts generate. The first is a plot of the most popular model families:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*DJ0FHUBr8YlPtjaSyk-Thg.png" /><figcaption>Plot of model families found on unsecured Ollama servers</figcaption></figure><p>As we can see, Meta’s Llama-based models are the most popular, with Qwen being second. Surprisingly, Google’s capable Gemma models don’t even make it into the top 5. Next up is model size:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*qogHc553EJjHOXhKaczW7g.png" /><figcaption>Plot of model sizes found on usecured Ollama servers</figcaption></figure><p>Not surprisingly, the 3.2B-10B bracket is the most popular by far, which fits with Ollama’s target audience being individuals running consumer graphics cards which have at most 24GB of VRAM, and many being limited to 16GB. Another statistic is quantization types:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*hTVkexd_92OcSc5Kb4jYSA.png" /><figcaption>Plot of quantization types found on unsecured Ollama servers</figcaption></figure><p>We can see that Q4_K_M seems to be the preferred method, with 8 and 16 bit floating-point being next, followed by several other 4-bit schemes. That 5-bit quantization is barely in use at all is interesting, this is probably due to 4-bit performance being sufficient. Our final plot shows popularity by country:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*kPn_pEQE3kSZrW1mrpPRMA.png" /><figcaption>Plot of geographic location of unsecured Ollama servers</figcaption></figure><p>Interesting, not what I expected to see at all.</p><h4>Conclusions</h4><p>This project puts a spotlight on some serious security issues with one of the most popular pieces of software used by machine learning researchers and enthusiasts. Hopefully it will inspire anyone who is running ML software like Ollama on managed hosting or internet-connected servers to give some thought to securing their operations in the future.</p><p><em>Full source code for the scripts presented in this article, and the scripts which generate the reports and plots is available on github: </em><a href="https://github.com/un1tz3r0/leakix-ollama-search"><em>https://github.com/un1tz3r0/leakix-ollama-search</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e7c5e524325" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>