Repository navigation
Description
Hello,
We carried out an independent, free review of the public ProxyPool repository at commit cabcd96cc9f30d7bdbc872bb8a8c52760023c142, by reading the source only: we did not run the code and did not contact any running instance. Each item below was re-checked a second time against the source by an independent reviewer who did not see the first review's reasoning. High and medium items were re-checked in full; low and informational items on a random sample (30 of 76), and only re-checked items are listed.
This issue lists only reliability and correctness items: 30 (1 high, 6 medium, 14 low, 9 info). A small number of other items we would prefer to share through a private channel; please let us know how you would like to receive them.
Each item names the defect, its location, its consequence and a suggested fix. We are happy to share the full report or answer questions. Thank you for maintaining ProxyPool.
1. Proxy validator accepts ports that int() rejects, so one crawled entry permanently breaks list reads and the tester scan
- Severity: high
- CWE: CWE-1287
- Location:
proxypool/utils/proxy.py:37-38 - Data path: crawler JSON port -> Proxy(host, port) (schemas/proxy.py:10, type not enforced) -> getter.py:40 RedisClient.add -> redis.py:44 is_valid_proxy -> utils/proxy.py:14/38 is_port_valid: port.isdigit() True -> redis.py:50 ZADD stores the member -> every later list read: redis.py:141 all(), :92 randoms(), :151 batch() -> utils/proxy.py:60 int(port) raises ValueError -> server.py:104/117/144 HTTP 500; tester.py:126 aborts run_tests, caught only by @logger.catch at tester.py:133. For the host part, utils/proxy.py:29-31 isdigit then int raises inside the validator and aborts getter.run (getter.py:29-41).
Impact. A single stored entry makes /all, /random?count>1 and /random?area fail with HTTP 500, and makes the tester abort at the batch containing it on every cycle, so proxies scanned after it are never re-tested or removed. The entry itself is never tested and therefore never removed; the state persists in Redis across restarts until manual cleanup.
Suggested fix. Validate host and port by parsing: require ASCII digits (str.isdecimal() plus an ASCII check, or a regex [0-9]+), convert with int() and enforce 1..65535 before storing; use ipaddress.ip_address for the host. In convert_proxy_or_proxies skip and log items whose conversion fails instead of raising.
2. Failure of the anonymity-check reference request is charged to every proxy, so an outage or throttling of the echo service drains the pool
- Severity: medium
- CWE: CWE-755
- Location:
proxypool/processors/tester.py:51-62 - Data path: tester.py:52-55 direct session.get(TEST_ANONYMOUS_URL) without proxy inside the same try as the proxied checks -> exception from tester.py:13-23 -> except EXCEPTIONS at tester.py:106-109 -> self.redis.decrease(proxy) for the proxy under test and for every tester key -> redis.py:103-108 removes the member at PROXY_SCORE_MIN.
Impact. While the default anonymity echo service is unreachable or rejects the tester, every proxy loses one point per cycle and the pool gradually drains, until the API answers with an empty-pool error. The pool recovers after the service is back and the getter refills it. The trigger is an outage of an external dependency, not untrusted client input.
Suggested fix. Perform the reference (direct) request once per cycle, outside the per-proxy try; if it fails, skip anonymity scoring for the cycle instead of decreasing proxies. Distinguish exceptions raised by the reference request from those raised by the proxied request.
3. Helm liveness probe targets /random, so an empty pool or a configured API_KEY puts the pod into a restart loop
- Severity: medium
- CWE: not assigned
- Location:
kubernetes/templates/proxypool-deployment.yaml:26-33 - Data path: kubelet httpGet /random:5555 -> server.py:88 auth_required -> server.py:31 returns 400 without header when API_KEY is set; otherwise server.py:130 conn.random() -> redis.py:71 raises PoolEmptyException on an empty pool -> HTTP 500 -> probe failure x5 -> container restart (all three processes run in the container under supervisord).
Impact. Enabling the only access control the product has makes the shipped chart restart the container indefinitely; with authentication off, an empty pool (first start, or after the tester drained it) restarts the container that hosts the getter which would refill it.
Suggested fix. Add a dedicated unauthenticated health endpoint that checks process and Redis liveness only, and point the liveness probe at it; use /random at most as a readiness signal.
4. TEST_VALID_STATUS set from the environment is parsed as strings, so no response status ever matches and every proxy is decreased
- Severity: medium
- CWE: CWE-704
- Location:
proxypool/setting.py:85 - Data path: env TEST_VALID_STATUS -> setting.py:85 env.list(...) -> list of str -> tester.py:65 response.status (int) in TEST_VALID_STATUS is always false -> tester.py:74 self.redis.decrease(proxy) for every proxy every cycle.
Impact. Every proxy, including working ones, loses one point per cycle and is removed; the pool empties and the API returns empty-pool errors, silently, with no configuration error reported.
Suggested fix. Use env.list("TEST_VALID_STATUS", [200, 206, 302], subcast=int) and validate the values at startup.
5. ENABLE_LOG_FILE=false recursively deletes LOG_DIR at import time, and LOG_DIR may resolve to any absolute path
- Severity: medium
- CWE: CWE-73
- Location:
proxypool/setting.py:126-127 - Data path: env LOG_DIR -> setting.py:16 join(ROOT_DIR, LOG_DIR) -> setting.py:126-127 else: shutil.rmtree(LOG_DIR, ignore_errors=True), executed at import of proxypool.setting by every process (server, getter, tester, run.py).
Impact. Disabling file logging deletes, recursively and silently, the directory named by LOG_DIR in every process start; with an absolute LOG_DIR this is an arbitrary directory chosen by configuration (for example a shared log directory), with ignore_errors hiding partial failures.
Suggested fix. Never delete directories when logging is disabled; simply skip adding file sinks. If cleanup is wanted, restrict it to files created by the application inside a validated directory under ROOT_DIR.
6. Any exception from one crawler aborts the whole getter cycle, so later crawlers never run while the failure persists
- Severity: medium
- CWE: CWE-755
- Location:
proxypool/processors/getter.py:37-41 - Data path: getter.py:37-41 for crawler in self.crawlers: for proxy in crawler.crawl(): ... (no per-crawler try) -> exception propagates out of Getter.run -> @logger.catch at getter.py:29 logs and returns; scheduler.py:47-51 repeats the same order next cycle. Crawler order follows module order, and Daili66Crawler is the first public crawler.
Impact. While one source keeps producing the same malformed content, every crawler after it is skipped on every cycle, so the pool stops being replenished while the tester keeps removing proxies; the pool shrinks toward empty.
Suggested fix. Wrap each crawler (and each yielded item) in its own try/except, log and continue; validate parsed fields before int() in parsers.
7. Crawler fetches have no size cap and no total deadline, so one list site can stall the sequential getter or exhaust memory
- Severity: medium
- CWE: CWE-400
- Location:
proxypool/crawlers/base.py:16-22 - Data path: crawlers/base.py:16-22 requests.get(url, timeout=GET_TIMEOUT, verify=False) -> response.text reads the whole body -> parse; getter.py:37-41 runs crawlers sequentially; xiaoshudaili.py:21 does such a fetch inside Getter() construction.
Impact. A slow or oversized response keeps the single getter loop blocked far beyond GET_TIMEOUT or grows its memory without bound (the Helm container has a 200Mi limit shared by all three processes), stopping replenishment of the pool.
Suggested fix. Stream responses with a byte cap (stream=True and iter_content with a maximum), enforce a total deadline per fetch, and run crawlers with an overall per-cycle time budget.
8. Plugin loading uses finder.find_module, removed in Python 3.12, while README promises Python 3.6+
- Severity: low
- CWE: CWE-477
- Location:
proxypool/crawlers/__init__.py:9 - Data path: run.py:1 -> scheduler.py:3-5 -> processors/getter.py:4 and tester.py:11 import proxypool.crawlers / proxypool.testers -> crawlers/init.py:9 and testers/init.py:9 loader.find_module(name).load_module(name); pkgutil.walk_packages yields FileFinder objects, whose find_module method no longer exists in Python 3.12.
Impact. When ProxyPool is run from source on Python 3.12 or later, every process fails at import with AttributeError, although the README states Python 3.6+. The shipped Docker image (python:3.11) is not affected, and the failure is visible immediately at startup.
Suggested fix. Replace the loader loop with importlib.import_module(f"{name}.{name}") over pkgutil.walk_packages(path, prefix=name + "."), and declare the supported Python range consistently in README and packaging.
9. Tester exceptions outside a fixed list are swallowed without logging and leave the proxy score unchanged
- Severity: low
- CWE: CWE-755
- Location:
proxypool/processors/tester.py:106-111 - Data path: tester.py:55/59 resp_json["origin"] or other calls inside the try at tester.py:46-104 -> exception not matched by except EXCEPTIONS (tester.py:106) -> propagates out of test() -> asyncio.gather(..., return_exceptions=True) at tester.py:129 discards it, no log.
Impact. Proxies whose test fails this way are neither decreased nor promoted: a dead proxy that once reached the max score keeps being served first indefinitely; if TEST_ANONYMOUS_URL points to a service that answers without "origin", scoring of the whole pool freezes. Nothing is logged.
Suggested fix. Catch Exception at the end of Tester.test, log it with the proxy, and treat an unclassified failure of the proxied request as a failed test; inspect the results returned by gather.
10. PROXY_RAND_KEY_DEGRADED is read from the TEST_ANONYMOUS variable, coupling sub-pool fallback to the anonymity test
- Severity: low
- CWE: not assigned
- Location:
proxypool/setting.py:60 - Data path: setting.py:60 PROXY_RAND_KEY_DEGRADED = env.bool("TEST_ANONYMOUS", True) and setting.py:77 TEST_ANONYMOUS = env.bool("TEST_ANONYMOUS", True) -> server.py:106, :119, :128 fallback to the universal pool.
Impact. Sub-pool requests silently fall back to universal-pool proxies that did not pass the sub-pool tester, and the fallback cannot be disabled without also disabling the anonymity test (or vice versa); degraded answers are not marked.
Suggested fix. Read a dedicated variable (e.g. PROXY_RAND_KEY_DEGRADED) and document it; optionally mark degraded responses.
11. The error log rotates without retention, so rotated error logs accumulate without bound
- Severity: low
- CWE: CWE-779
- Location:
proxypool/setting.py:123-125 - Data path: setting.py:121-122 runtime sink has retention=LOG_RETENTION; setting.py:124-125 error sink has rotation=LOG_ROTATION and no retention.
Impact. Rotated 500MB error-log files are never removed, contrary to the documented LOG_RETENTION (README.md:295), and fill the disk over time.
Suggested fix. Pass retention=LOG_RETENTION to the error sink.
12. Deployment selector includes chart and app version labels, so a version bump makes helm upgrade fail
- Severity: low
- CWE: not assigned
- Location:
kubernetes/templates/proxypool-deployment.yaml:10-12 - Data path: proxypool-deployment.yaml:10-12 matchLabels: include "proxypool.labels" -> _helpers.tpl:38-45 includes helm.sh/chart (chart version) and app.kubernetes.io/version; spec.selector of apps/v1 Deployment is immutable.
Impact. The documented upgrade path breaks on the first version bump; recovery requires deleting the Deployment.
Suggested fix. Use only selectorLabels (_helpers.tpl:50-53) in spec.selector.matchLabels.
13. decrease() decides removal on a separately read score (non-atomic read-modify-write) when several testers share one Redis
- Severity: low
- CWE: CWE-362
- Location:
proxypool/storages/redis.py:100-108 - Data path: redis.py:100-108 ZINCRBY, then ZSCORE, then ZREM as separate round trips; another tester's write can land in between.
Impact. A proxy just set to the max score by another tester can be deleted; a concurrent double decrement yields None <= int, a TypeError swallowed by gather.
Suggested fix. Use a Lua script or MULTI/WATCH, or take the removal decision from the ZINCRBY return value.
14. Crawler URLs that depend on the current date or hour are computed once per process and never refreshed in the long-running getter
- Severity: low
- CWE: not assigned
- Location:
proxypool/crawlers/public/docip.py:16 - Data path: docip.py:16 and ihuan.py:13-14 class-body strftime at import; xiaoshudaili.py:16-35 resolves pages once in init (empty list after a startup failure); Getter() is constructed once (scheduler.py:45).
Impact. After the first day the getter keeps requesting stale pages; a startup failure disables XiaoShuCrawler until restart.
Suggested fix. Compute URLs inside crawl() on every cycle.
15. Tester makes one direct request to the anonymity echo service per proxy per cycle for a value that is constant within the cycle
- Severity: low
- CWE: not assigned
- Location:
proxypool/processors/tester.py:51-56 - Data path: tester.py:52-55 direct request inside Tester.test, executed for every proxy.
Impact. Outbound requests to a public third-party service grow linearly with the pool, which also raises the chance of throttling that the related finding turns into pool drain.
Suggested fix. Fetch the reference origin once per cycle.
16. Production gevent (and tornado WSGIContainer) server runs blocking redis-py I/O without monkey patching, serialising requests
- Severity: low
- CWE: not assigned
- Location:
proxypool/scheduler.py:61-68 - Data path: scheduler.py:63-68 WSGIServer without gevent.monkey.patch_all(); handlers call synchronous redis-py.
Impact. One slow request (e.g. /all or area on a large pool) delays all other clients.
Suggested fix. Call gevent.monkey.patch_all() before imports, or use a threaded WSGI server.
17. Pool size cap PROXY_NUMBER_MAX is checked once per getter cycle and only for the main key
- Severity: low
- CWE: CWE-770
- Location:
proxypool/processors/getter.py:22-41 - Data path: getter.py:22-27 is_full() checked at getter.py:35 only; the loop getter.py:37-41 adds without re-checking; setting.py:63 hard-coded.
Impact. Redis can grow past the cap by a whole cycle of crawl output (list sites are untrusted), against the Helm Redis memory limit of 100Mi.
Suggested fix. Check capacity per add (or use a Lua script) and make the cap configurable.
18. Validity test accepts a bare status code (including 302 with redirects disabled) over plain HTTP, and one success sets the max score
- Severity: low
- CWE: not assigned
- Location:
proxypool/processors/tester.py:63-72 - Data path: tester.py:63-72 session.get(TEST_URL, proxy=..., allow_redirects=False) -> status in TEST_VALID_STATUS -> redis.max(proxy).
Impact. Proxies that answer every request themselves (captive portals, redirecting or intercepting proxies) get the top score and are served first.
Suggested fix. Verify the response content (e.g. a known marker or hash) and raise scores gradually.
19. Scheduler handles only KeyboardInterrupt; on SIGTERM the parent exits and child processes keep running
- Severity: low
- CWE: not assigned
- Location:
proxypool/scheduler.py:97-131 - Data path: scheduler.py:97-141 handles KeyboardInterrupt only; children are non-daemon multiprocessing.Process.
Impact. Orphaned getter/tester keep writing to Redis and the orphaned server keeps the port; a restart runs duplicates or fails to bind.
Suggested fix. Install a SIGTERM handler that terminates and joins children.
20. GET /all returns the entire pool with no limit or pagination
- Severity: low
- CWE: CWE-770
- Location:
proxypool/processors/server.py:144-151 - Data path: server.py:144-151 conn.all() -> redis.py:141 full ZRANGEBYSCORE -> full list built in memory and returned.
Impact. Memory and CPU per request proportional to pool size, without a cap on concurrent requests.
Suggested fix. Add pagination and a maximum page size.
21. Area filter loads the full pool and does one GeoIP lookup per proxy on every request
- Severity: low
- CWE: not assigned
- Location:
proxypool/processors/server.py:102-113 - Data path: server.py:104-107 conn.all() (twice on the degraded path) -> server.py:74 get_country_iso per proxy, no cache.
Impact. O(pool size) Redis transfer and GeoIP lookups for a request that returns one proxy.
Suggested fix. Cache country per proxy at insertion time or keep per-country sets.
22. Crawler regexes use non-raw strings with invalid escape sequences
- Severity: info
- CWE: not assigned
- Location:
proxypool/crawlers/public/ihuan.py:23 - Data path: ihuan.py:23 re.compile("([\d:.]).?
") and ip89.py:20, ip3366.py:21, iphai.py:25 use non-raw string literals containing \d, \s, .
Impact. Warnings at import today; a syntax error when the escapes become invalid.
Suggested fix. Use raw string literals for all regular expressions.
23. Deploy workflow builds and applies files that do not exist in the repository
- Severity: info
- CWE: not assigned
- Location:
.github/workflows/deploy.yml:36-42 - Data path: deploy.yml:38 docker-compose -f build.yaml build and :42 cat deployment.yml; neither file is in the copy.
Impact. The deploy job fails at that step; the workflow cannot deploy as written.
Suggested fix. Remove the workflow or point it at existing files.
24. No automated tests exist and CI publishes images without executing any project code
- Severity: info
- CWE: not assigned
- Location:
.github/workflows/build.yml:13-45 - Data path: Repository contains no tests; build.yml:36-45 builds and pushes germey/proxypool:latest/:master without a test step; values.yaml:5-6 deploys :master with imagePullPolicy Always.
Impact. Regressions in authentication, key validation, scoring or parsing ship to the published image unnoticed.
Suggested fix. Add unit tests for the validator, scoring and API, and run them in CI before pushing images.
25. Non-ASCII API-KEY header raises TypeError (HTTP 500) instead of returning 403
- Severity: info
- CWE: not assigned
- Location:
proxypool/processors/server.py:33-36 - Data path: server.py:29-33 hmac.compare_digest(api_key, API_KEY) with str arguments containing non-ASCII characters raises TypeError -> 500.
Impact. Malformed keys produce server errors instead of the documented 403; no bypass.
Suggested fix. Compare encoded bytes: hmac.compare_digest(api_key.encode(), API_KEY.encode()).
26. Zhandaye crawler appends detail URLs to a class-level list every cycle (crawler disabled by default)
- Severity: info
- CWE: not assigned
- Location:
proxypool/crawlers/public/zhandaye.py:42 - Data path: zhandaye.py:20 urls = [] class attribute; :42 self.urls.append(url) every crawl_catalog().
Impact. Work and memory grow with uptime when enabled.
Suggested fix. Build the list locally per cycle.
27. Numeric settings are not range-checked
- Severity: info
- CWE: not assigned
- Location:
proxypool/setting.py:67-75 - Data path: setting.py:56-75 env.int without validation -> scheduler.py:36/51 time.sleep, tester.py:121/126.
Impact. Misconfiguration breaks loops or limits without a startup error.
Suggested fix. Validate ranges at startup.
28. Importing a crawler module globally disables urllib3 warnings
- Severity: info
- CWE: not assigned
- Location:
proxypool/crawlers/public/seofangfa.py:7 - Data path: seofangfa.py:7 requests.packages.urllib3.disable_warnings().
Impact. Certificate warnings for every process are suppressed, hiding the verify=False behaviour.
Suggested fix. Remove the global call.
29. Every processor imports the whole application, so getter and tester also open GeoLite2 and build the Flask app
- Severity: info
- CWE: not assigned
- Location:
proxypool/utils/geo.py:6-12 - Data path: run.py:1 -> scheduler.py:3-5 imports server, getter and tester.
Impact. Extra memory and startup work in each process.
Suggested fix. Import processors lazily in run_* methods.
30. decrease() on a non-member re-creates it with score -1 until the following ZREM
- Severity: info
- CWE: not assigned
- Location:
proxypool/storages/redis.py:103-108 - Data path: redis.py:103 ZINCRBY creates the member; redis.py:108 removes it after a separate ZSCORE.
Impact. A transient entry exists between commands and can be observed by another process.
Suggested fix. Check membership atomically or use a script.
Activity