{
  "id": "CB-UBU-NET-009",
  "standard": "ubuntu",
  "version": "0.1.2",
  "url": "https://baselines.cirsec.org/b/ubuntu/v0.1.2/CB-UBU-NET-009",
  "json": "https://baselines.cirsec.org/b/ubuntu/v0.1.2/CB-UBU-NET-009.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/v0.1.2/CB-UBU-NET-009.yml",
  "profiles_effective": [
    "core",
    "server",
    "server-hardened",
    "desktop",
    "desktop-hardened"
  ],
  "license": "Text CC BY 4.0, code Apache-2.0",
  "attribution": "CIRSEC Baselines, https://baselines.cirsec.org",
  "control": {
    "id": "CB-UBU-NET-009",
    "title": "Disable IP forwarding unless the system is a router",
    "finding": {
      "title": "The system forwards packets between networks",
      "description": "A host that forwards packets can be used to reach networks that should be separated from the one the attacker is on."
    },
    "status": "active",
    "profiles": [
      "core"
    ],
    "risk": {
      "severity": "medium"
    },
    "assessment": "automated",
    "tags": [
      "sysctl",
      "network",
      "routing",
      "ipv6"
    ],
    "description": "With IP forwarding on, the kernel routes packets received on one interface to another, like a\nrouter. It is controlled by `net.ipv4.ip_forward` (an alias of `net.ipv4.conf.all.forwarding`),\n`net.ipv4.conf.default.forwarding` for interfaces created later, and\n`net.ipv6.conf.all.forwarding` / `net.ipv6.conf.default.forwarding` for IPv6. Ubuntu ships\nforwarding off. This control checks all five values against the `ip_forward` parameter.\n",
    "rationale": "A host that is not meant to route should never relay traffic: forwarding lets an attacker who\ncontrols one of its networks reach the others through it, bypassing network filtering.\n",
    "impact": "Hosts that legitimately route need forwarding: routers, VPN gateways, and hosts running\ncontainers or virtual machines with NAT (Docker, libvirt, LXC turn it on at start). On those,\nset the `ip_forward` parameter to `1` in the tailoring file, and filter forwarded traffic in\nthe firewall (CB-UBU-NET-006).\n",
    "notes": "Writing `net.ipv4.ip_forward` also resets several per-interface settings (the kernel documentation\ncalls it special), so the fix writes it first. IPv6 checks only run when the IPv6 stack is\npresent.\n",
    "setting": {
      "location": "sysctl `net.ipv4.ip_forward`, `net.ipv4.conf.{all,default}.forwarding`, `net.ipv6.conf.{all,default}.forwarding`, persisted in `/etc/sysctl.d/`",
      "default_value": "0",
      "recommended_value": "{{ ip_forward }} (0 except on routers)"
    },
    "parameters": [
      {
        "name": "ip_forward",
        "type": "integer",
        "description": "Expected forwarding state, 0 for a host, 1 for a router or container host.",
        "default": 0,
        "minimum": 0,
        "maximum": 1
      }
    ],
    "audit": {
      "manual": "Run `sysctl net.ipv4.ip_forward net.ipv4.conf.all.forwarding net.ipv4.conf.default.forwarding net.ipv6.conf.all.forwarding net.ipv6.conf.default.forwarding`.\nEvery value must be `{{ ip_forward }}`. Then check that no file in `/etc/sysctl.d/`,\n`/run/sysctl.d/`, `/usr/lib/sysctl.d/` or `/etc/sysctl.conf` sets another value.\n",
      "checks": [
        {
          "id": "ipv4-ip-forward",
          "engine": "sysctl",
          "description": "net.ipv4.ip_forward.",
          "spec": {
            "key": "net.ipv4.ip_forward",
            "value": "{{ ip_forward }}"
          }
        },
        {
          "id": "ipv4-all",
          "engine": "sysctl",
          "description": "net.ipv4.conf.all.forwarding.",
          "spec": {
            "key": "net.ipv4.conf.all.forwarding",
            "value": "{{ ip_forward }}"
          }
        },
        {
          "id": "ipv4-default",
          "engine": "sysctl",
          "description": "net.ipv4.conf.default.forwarding.",
          "spec": {
            "key": "net.ipv4.conf.default.forwarding",
            "value": "{{ ip_forward }}"
          }
        },
        {
          "id": "ipv6-all",
          "engine": "sysctl",
          "description": "net.ipv6.conf.all.forwarding.",
          "facts": [
            "ipv6"
          ],
          "spec": {
            "key": "net.ipv6.conf.all.forwarding",
            "value": "{{ ip_forward }}"
          }
        },
        {
          "id": "ipv6-default",
          "engine": "sysctl",
          "description": "net.ipv6.conf.default.forwarding.",
          "facts": [
            "ipv6"
          ],
          "spec": {
            "key": "net.ipv6.conf.default.forwarding",
            "value": "{{ ip_forward }}"
          }
        }
      ]
    },
    "remediation": {
      "manual": "Add to `/etc/sysctl.d/60-cirsec.conf`, `net.ipv4.ip_forward` first:\n```\nnet.ipv4.ip_forward = {{ ip_forward }}\nnet.ipv4.conf.all.forwarding = {{ ip_forward }}\nnet.ipv4.conf.default.forwarding = {{ ip_forward }}\nnet.ipv6.conf.all.forwarding = {{ ip_forward }}\nnet.ipv6.conf.default.forwarding = {{ ip_forward }}\n```\nRemove other assignments of these keys, then run `sysctl --system`.\n",
      "effects": {
        "restart": "none",
        "disruption": "low",
        "lockout_risk": false
      },
      "rollback": "Remove the lines from `/etc/sysctl.d/60-cirsec.conf` and set the previous values with `sysctl -w`.\n",
      "scripts": [
        {
          "id": "ipv4-ip-forward",
          "from_check": "ipv4-ip-forward"
        },
        {
          "id": "ipv4-all",
          "from_check": "ipv4-all"
        },
        {
          "id": "ipv4-default",
          "from_check": "ipv4-default"
        },
        {
          "id": "ipv6-all",
          "from_check": "ipv6-all"
        },
        {
          "id": "ipv6-default",
          "from_check": "ipv6-default"
        }
      ]
    },
    "references": [
      {
        "title": "Linux kernel documentation - IP Sysctl",
        "url": "https://docs.kernel.org/networking/ip-sysctl.html",
        "publisher": "The Linux Kernel Organization",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "sysctl.d(5), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man5/sysctl.d.5.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "ANSSI-BP-028 v2.0 - Recommandations de configuration d'un système GNU/Linux (R12)",
        "url": "https://messervices.cyber.gouv.fr/documents-guides/fr_np_linux_configuration-v2.0.pdf",
        "publisher": "ANSSI",
        "kind": "guide",
        "accessed": "2026-10-19"
      }
    ],
    "mappings": [
      {
        "framework": "anssi-linux",
        "framework_version": "2.0",
        "id": "R12",
        "relation": "partial",
        "note": "R12 lists many IPv4 settings; this control covers forwarding."
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "CM-7",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1090"
      },
      {
        "framework": "cwe",
        "id": "CWE-923"
      }
    ],
    "authors": [
      {
        "name": "Alice",
        "github": "Sn0wAlice"
      }
    ],
    "verified": [
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "20.04"
        ],
        "environment": "Proxmox VM, Ubuntu 20.04 cloud image, kernel 5.4.0-216-generic, BIOS boot",
        "notes": "Passes on a fresh install; still passes after remediation and reboot."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "22.04"
        ],
        "environment": "Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic, BIOS boot",
        "notes": "Passes on a fresh install; still passes after remediation and reboot."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "24.04"
        ],
        "environment": "Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic, BIOS boot",
        "notes": "Passes on a fresh install; still passes after remediation and reboot."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "26.04"
        ],
        "environment": "Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic, BIOS boot",
        "notes": "Passes on a fresh install; still passes after remediation and reboot."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}