GithubHelp home page GithubHelp logo

Comments (5)

rikatz avatar rikatz commented on May 23, 2024 1

@jkroepke thanks for this issue (and all of the other reports ;) )

Anything we can use to improve security on this case is acceptable. That said, can we work on something with https://kubernetes.io/docs/reference/access-authn-authz/validating-admission-policy/ so we don't need to rely on any external webhook?

from ingress-nginx.

k8s-ci-robot avatar k8s-ci-robot commented on May 23, 2024

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

from ingress-nginx.

longwuyuan avatar longwuyuan commented on May 23, 2024

from ingress-nginx.

jkroepke avatar jkroepke commented on May 23, 2024

AFAIK, normal regex lib is PCRE but K8S uses RE2 kubernetes.github.io/ingress-nginx/user-guide/ingress-path-matching/#regular-expression-support

Okay, if Kubernetes already does a regex validation, the idea could be drop.

I'm I have a built-in solution in mind. Not everyone has the power or capability to setup Open Policy Agent or Kyverno. Before someone is going deeper with REGO, I would more recommend to take an alternative ingress controller.

I'm coming from https://kubernetes.github.io/ingress-nginx/faq/#validation-of-path, so I'm aware of the bullet points.

from ingress-nginx.

jkroepke avatar jkroepke commented on May 23, 2024

While I was writing the issue, I had more in my mind to improve the validate inside ingress-nginx:

  • invalidAliasDirective = regexp.MustCompile(`(?s)\s*alias\s*.*;`)
    invalidRootDirective = regexp.MustCompile(`(?s)\s*root\s*.*;`)
    invalidEtcDir = regexp.MustCompile(`/etc/(passwd|shadow|group|nginx|ingress-controller)`)
    invalidSecretsDir = regexp.MustCompile(`/var/run/secrets`)
    invalidByLuaDirective = regexp.MustCompile(`.*_by_lua.*`)
  • func ValidatePathType(ing *networking.Ingress) error {
    if ing == nil {
    return fmt.Errorf("received null ingress")
    }
    var err error
    for _, rule := range ing.Spec.Rules {
    if rule.HTTP != nil {
    for _, path := range rule.HTTP.Paths {
    if path.Path == "" {
    continue
    }
    if path.PathType == nil || *path.PathType != implSpecific {
    if isValid := validPathType.MatchString(path.Path); !isValid {
    err = errors.Join(err, fmt.Errorf("path %s cannot be used with pathType %s", path.Path, string(*path.PathType)))
    }
    }
    }
    }
    }
    return err
    }

and toggle them behind validate-strict-path, to have an opt-in unless we are on 2.0.0.

https://kubernetes.io/docs/reference/access-authn-authz/validating-admission-policy/ may fits, too. But its would be a strategy design, we future validation should done by Kubernetes it-self or nginx.

While ValidatingAdmissionPolicy sound great first, it my not work, if ingress-nginx runs on a namespace scope. ValidatingAdmissionWebhook, doesn't work on namespace scope, too. But ingress-nginx will reject invalid ingress objects without ValidatingAdmissionWebhook, too.

from ingress-nginx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.