SafeLine icon indicating copy to clipboard operation
SafeLine copied to clipboard

[Bug] SafeLine reports almost all requests as 502 when using Traefik plugin

Open dejikoru-hub opened this issue 3 weeks ago • 4 comments

SafeLine version

9.4.3

Bug description

What happened:

SafeLine reports almost all requests as 5xx errors originating from SafeLine when using the official Traefik plugin, even though the protected application is accessible and normal requests return HTTP 200.

The statistics dashboard showed:

  • 694 total requests
  • 688 5xx errors
  • 99.14% error rate

The 5xx tooltip showed Error from SafeLine: 688 and Error from upstream server: 0.

The safeline-luigi log contained an aggregated statistics entry with status 502 and an empty site_id:

INSERT INTO "statistics_basics"
("time","type","key","content_type","method","path","site_id","count")
VALUES (1794245166,'waf_status_code','502','','','','',144)

Two different SQL injection tests produced different results:

  1. A test using the query parameter test=1' OR '1'='1 was not blocked: curl received HTTP 200. SafeLine recorded this exact request in Attacks → Logs as Timeout, with Audited / Allow and No Response in the response details. One attempt took approximately 2.47 seconds; a later attempt returned HTTP 200 in approximately 0.046 seconds.

  2. A test using ?1=1%20and%202=2 was blocked: curl received HTTP 403 with the SafeLine block message. The event appeared in Attacks → Logs as Blocked / SQL Inj.

The semantic analysis configuration shows Balance Mode selected for SQL injection.

What did I expect:

  • Successful HTTP 200 responses should not be counted as SafeLine 502 errors.
  • The Timeout / Allow / No Response event for the first test should be explained, including why the request was allowed.
  • I would like to know whether the different results for the two test requests are expected.

Environment:

  • SafeLine CE 9.4.3
  • Traefik v3.7
  • traefik-safeline plugin v1.4.0
  • Ubuntu 24.04 LTS
  • Docker Compose
  • Protected application: self-hosted NetBird dashboard

Traffic path:

Client → Traefik → SafeLine detector via plugin → NetBird dashboard

Traefik and safeline-detector share a Docker network. The detector listens on TCP port 8000. No applications are configured in the SafeLine Applications page.

Traefik middleware:

http:
  middlewares:
    safeline-check:
      plugin:
        safeline:
          addr: "safeline-detector:8000"

Additional diagnostics:

  • safeline-detector is currently running and reports healthy.
  • Recent Traefik and detector Docker logs showed no error corresponding to the test request.
  • During an earlier startup, detector logs showed connection refusals to 127.0.0.1:18001, and FVM logged Push FSL response(502). Later FVM logs reported Push FSL success. It is unclear whether those earlier errors are related.
  • A potentially related plugin issue is https://github.com/chaitin/traefik-safeline/issues/8, but I did not observe its broken pipe message.

Questions for the maintainers:

  1. Why are successful requests counted as SafeLine 502 errors?
  2. Does the Traefik plugin report upstream response statuses to SafeLine? Could this affect the statistics?
  3. What does Timeout / Allow / No Response mean in this setup, and which logs or debug settings should be enabled to find the cause?
  4. Is an entry in SafeLine Applications required when using the Traefik plugin?
  5. Is the different behavior between the two SQL injection tests expected, or does the first event indicate a detection problem?
  6. Is there a recommended configuration or fix for reliable detection and statistics with this integration?

Steps to reproduce (if available)

  1. Deploy SafeLine and Traefik using Docker Compose.
  2. Configure the traefik-safeline plugin to connect to safeline-detector:8000.
  3. Attach the middleware to the Traefik router for a web application.
  4. Open and browse the application, then check Statistics → Traffic Analysis for 5xx errors.
  5. Send these two test requests, replacing example.com with the protected domain:
curl -iG --data-urlencode "test=1' OR '1'='1" https://example.com/
curl -i 'https://example.com/?1=1%20and%202=2'
  1. Compare the HTTP responses with the events in Attacks → Logs.

In my deployment, the first test returned HTTP 200 and was logged as Timeout / Audited / Allow / No Response; the second returned HTTP 403 and was logged as Blocked / SQL Inj.

Logs or screenshots (optional)

No response

dejikoru-hub avatar Nov 09 '26 18:11 dejikoru-hub

I found a similar report in the Traefik plugin repository: https://github.com/chaitin/traefik-safeline/issues/6

That user also reports that blocking works while the SafeLine dashboard continuously shows gateway timeouts. Is this the same issue as the 502 statistics and Timeout / Allow events in my deployment? Is there a recommended fix or configuration?

dejikoru-hub avatar Nov 09 '26 18:11 dejikoru-hub

Hi @dejikoru-hub, thanks for putting together such a thorough report — really appreciate it.

To address your questions:

  1. The difference between the two test requests is expected. SQL injection detection runs in Balanced mode by default, which catches 1=1 and 2=2 right away. 1' OR '1'='1 is a subtler variant, and it gets detected once you switch the Semantic Analysis SQL injection protection to Strict Mode.

  2. Unfortunately, we don't have integration documentation for the Traefik plugin at the moment — sorry about that.

  3. As for the 502 statistics, we'd like to dig into it a bit further. Could you share the error logs from both your site and the upstream? Once we've had a look, we'll follow up with you.

Windsley avatar Nov 11 '26 08:11 Windsley

Hi @Windsley ! Thanks for your response.

I have switched the SQL injection protection to Strict mode. I will test it again and share the results.

Regarding the 502 statistics, could you clarify which specific logs you need? My setup uses Traefik with the SafeLine plugin, and the affected requests are routed to several services. Do you need Traefik logs, SafeLine detector logs, or logs from the backend applications? Please also let me know what time range and log level would be useful.

I will collect the relevant logs and remove any sensitive information before sharing them.

dejikoru-hub avatar Nov 11 '26 13:11 dejikoru-hub

Hi @dejikoru-hub !Please provide the logs listed below for the 5–10 minutes before and after the 502 anomaly, covering the same time window, with timestamps and time zones noted:

  • Traefik access logs: JSON format preferred, retain normal 200 responses, including request time, domain, path, DownstreamStatus and OriginStatus.
  • Traefik runtime logs: including error outputs from the SafeLine plugin.
  • Logs from the safeline-detector and safeline-luigi containers.
  • Access logs and error logs of the corresponding backend service: start with one reproducible service only.

Also provide a URL for the reproduction request, the actual HTTP response code, and screenshots of the breakdown items for "Error returned by SafeLine / Error returned by upstream" shown in the SafeLine 5xx prompt.

asdasdipqn-oss avatar Nov 12 '26 06:11 asdasdipqn-oss