DevSecOps, Docker + UFW and API protection from hacking

How to close UFW bypass via Docker, protect webhooks with HMAC signature, configure CSP and pass OWASP Top 10 security audit.

TL;DR · Key Answer

Docker by default modifies the DOCKER-USER iptables chain, bypassing UFW rules. To protect the database and internal ports, bind services to 127.0.0.1 and filter traffic in ufw-docker or DOCKER-USER.

Checklist

  • Always bind internal DB/Redis ports as 127.0.0.1:5432:5432, not 0.0.0.0.
  • Check the X-Signature (HMAC-SHA256 + timingSafeEqual) on every payment and bot webhook.
  • Configure strict Content-Security-Policy and X-Frame-Options in middleware.

Forum Discussions (vbcd4u.com)

Все обсуждения →

Engineering Guides (MurdaSoft)

FAQ

Why doesn't UFW block the port opened in docker-compose?

Docker adds DNAT rules to iptables before the INPUT chain, which is managed by UFW. Use binding on 127.0.0.1 or rules in the DOCKER-USER chain.