Skip to content

Validation of URLs does not comply with RFCs (e.g. app-root annotation, ingress path) #12822

Open
@Phil1602

Description

@Phil1602

What happened:

An ingress containing an anchor within the app-root redirect annotation fails validation:

nginx.ingress.kubernetes.io/app-root: /_dashboards/app/home#/

What you expected to happen:

After updating Ingress-Nginx to 1.12.0 release, we encountered the following issue with app-root annotation. The "issue" itself was not introduced within 1.12.0 but was realized because of the new default enablement of --enable-annotation-validation (see flags.go).

So far so good, we are wondering why this specific annotation validation should fail in our case:

W0211 15:42:00.195018 7 validators.go:237] validation error on ingress my-namespace/my-ingress: annotation app-root contains invalid value /_dashboards/app/home#/

The Ingress itself is related to an OpenSearch installation which uses anchor/fragments for many aspects of client-side logic and deeplinking.

We totally aggree that this is an edge case and in our case we can solve the problem by adjusting the value to /_dashboards/app/home, since the fragment/anchor is appended properly on client side again.

But we are wondering if the validation itself is spec conform about URL/URI pattern.

So in our opinion, the fragment/anchor part of the redirect seems to be valid and might be worth to add to valid options?

Relevant lines of code:

Annotation Validation of URLs via regex:

Additional, specific validation to app-route annotation via net/url lib:

NGINX Ingress controller version (exec into the pod and run /nginx-ingress-controller --version):

-------------------------------------------------------------------------------
NGINX Ingress controller
  Release:       v1.12.0
  Build:         ba73b2c24d355f1cdcf4b31ef7c5574059f12118
  Repository:    https://github.com/kubernetes/ingress-nginx
  nginx version: nginx/1.25.5

-------------------------------------------------------------------------------

Kubernetes version (use kubectl version): Server Version: v1.30.8-eks-2d5f260 (not related to the issue)

Environment:
Since this issue is related to annotation validation within the nginx code (see above), it is not related to any infrastructure, kernel or hardware versions at all.

How to reproduce this issue:
Ingress which triggers this issue:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-app-root-anchor
  annotations:
    nginx.ingress.kubernetes.io/app-root: /foo#/
spec:
  ingressClassName: nginx
  rules:
  - host: <foo.example.com>
    http:
      paths:
      - backend:
          service:
            name: foo
            port:
              number: 443
        path: /
        pathType: Prefix

Ingress-Nginx config consists of at least Medium risk level according to the docs.

annotations-risk-level: Critical

Anything else we need to know:

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.needs-kindIndicates a PR lacks a `kind/foo` label and requires one.needs-prioritytriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions