Skip to content

Netbird API accepts policies with multiple rules, but ignores all rules except the first. #3583

Open
@Chilinot

Description

@Chilinot

Describe the problem

The Netbird API specifies that you can create policies with multiple rules. However if you try and do this, netbird will create the policy but only apply the first rule in the list, ignoring the rest. No error is returned to the user.

To Reproduce

  1. Send this JSON payload to the API:
{
    "description": "Access rules for the DBA team",
    "enabled": true,
    "name": "database-admins",
    "rules": [
        {
            "action": "accept",
            "bidirectional": true,
            "description": "Allow accessing PostgreSQL servers",
            "enabled": true,
            "name": "PostgreSQL",
            "ports": [
                "5432"
            ],
            "protocol": "tcp",
            "source_groups": [
                "cvhicgaqfhcs73cg8650"
            ],
            "target_groups": [
                "cvhqklaqfhcs73cfdpj0"
            ]
        },
        {
            "name": "second rule",
            "description": "This rule will be ignored by the API",
            "action": "accept",
            "bidirectional": true,
            "enabled": true,
            "ports": [
                "22"
            ],
            "protocol": "tcp",
            "source_groups": [
                "foobar"
            ],
            "target_groups": [
                "qwerty"
            ]
        }
    ]
}
  1. You get the following in response:
{
    "description": "Access rules for the DBA team",
    "enabled": true,
    "id": "cvihva2qfhcs73e21tb0",
    "name": "database-admins",
    "rules": [
        {
            "action": "accept",
            "bidirectional": true,
            "description": "Allow accessing PostgreSQL servers",
            "destinations": [
                {
                    "id": "cvhqklaqfhcs73cfdpj0",
                    "name": "res-dev-postgresql",
                    "peers_count": 0,
                    "resources_count": 0
                }
            ],
            "enabled": true,
            "id": "cvihva2qfhcs73e21tb0",
            "name": "PostgreSQL",
            "ports": [
                "5432"
            ],
            "protocol": "tcp",
            "sources": [
                {
                    "id": "cvhicgaqfhcs73cg8650",
                    "name": "eng-dba",
                    "peers_count": 0,
                    "resources_count": 0
                }
            ]
        }
    ],
    "source_posture_checks": null
}

Expected behavior

That the API either returns a 400 error indicating that this is incorrect. Or that both rules are applied to the policy.

Are you using NetBird Cloud?

Self hosting.

NetBird version

Management service version: 0.38.2

Is any other VPN software installed?

No

Debug output

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Have you tried these troubleshooting steps?

  • Checked for newer NetBird versions
  • Searched for similar issues on GitHub (including closed ones)
  • Restarted the NetBird client
  • Disabled other VPN software
  • Checked firewall settings

Metadata

Metadata

Assignees

No one assigned

    Labels

    apibugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions