Skip to content

Use more clever certificate subject #617

Closed

Description

@sbernauer

Well, currently all certificates get the subject CN=generated certificate for pod.
This imposes real security problems as shown in the code links below.

We should change that, so that one can actually use the subject for authorization. Things that come to my mind:

  1. OPA rules for Kafka using mTLS
  2. NiFi OPA rules and config
  3. @siegfriedweber mentioned the OpenSearch implementation also struggles with our current subject

Activity

  1. nightkr commented on Jul 8, 2025

    @nightkr
    Contributor

    The question is.. what would a good subject DN be? Node name is too broad to be useful (and is gonna cause bleed between different services that may or may not have a trust relationship..), the service scope should generally die in a fire, and pod name is too specific (you don't really want to distinguish between different replicas of the same service). The listener scope suffers from all of these problems at the same time, in addition to not really having a "primary" identity at all (it's just a bag of addresses, which works fine for SANs that we can have multiple of, but not so much for having to pick one subject DN).

    I think a reasonable way to do it would be to use the Pod's ServiceAccount (and Namespace), which gives the user a reasonable amount of control but is also already treated as the permission boundary for accessing the K8s API itself. In an ideal world, it might have been worth using SPIFFE (like Istio already does), but in practice (at least last I checked) tooling support for URI SANs is abysmal (and of course generally even worse for things that assume that the subject DN is the only meaningful part of the certificate, or that the subject DN is meaningful at all).

  2. NickLarsenNZ commented on Oct 10, 2025

    @NickLarsenNZ
    Member

    Do our products require that the Serving cert is also the one used for Client auth?

    I've always used completely separate certificates for that (for one or both of ZooKeeper and Kafka). That way you can use a general CA for the server cert (eg: internal PKI), and for mTLS you can use a super restricted CA that is added to the client auth trust store for node-to-node comms.

    I assume some of our products can't differentiate.

  3. lfrancke commented on Dec 15, 2025

    @lfrancke
    Member

    We decided to look at this for real now as it's needed for OpenSearch.

    The next/first step is a refinement where we discuss/brainstorm what a solution could look like, what we want to do and a recommendation how to continue so we can do a final go/no-go decision.

  4. moved this to Selected for Development in Stackable End-to-End Coordinationon Dec 15, 2025
  5. siegfriedweber commented on Feb 19, 2026

    @siegfriedweber
    Member

    The common name field has a limit of 64 characters (refer to RFC 5280). In contrast, pod names can be up to 253 characters, while namespaces are limited to 63 characters. FQDNs are therefore completely out of scope. As a result, addressing this issue will likely require the use of a non-meaningful identifier.

  6. lfrancke commented on Mar 19, 2026

    @lfrancke
    Member

    Please feel free to ignore me. The current subject is entirely static and non helpful at all. To me it seems as if anything we do is better than what we have today.

    @nightkr had the suggestion of using ServiceAccount + Namespace. If I understand her correctly it'd be something along the lines of CN=hdfs-datanode, O=default as a subject then. That seems reasonable to me. We just need some truncation logic but that's also fine with me. I guess the service accounts are mostly under our control anyway and it's just the namespace that's up to the user so I'd truncate that.

  7. nightkr commented on Mar 19, 2026

    @nightkr
    Contributor

    I don't remember saying that but it does make sense to me. :P

    I would suggest still keeping some kind of "this was generated by secret-operator" tag, both to discourage people (and especially pre-SAN legacy code) from trying to parse it (instead of looking at the SAN) and to avoid confusion w/ people expecting it it to map cleanly onto DNS/LDAP/whatever else.

    Can't speak for the OpenSearch case… "OpenSearch expects the CNs to be distinct, but doesn't care otherwise"?

  8. siegfriedweber commented on Mar 19, 2026

    @siegfriedweber
    Member

    ServiceAccount + Namespace

    This approach may present a potential solution. However, if users have the ability to deploy pods within a namespace, they could easily create a pod that uses the OpenSearch ServiceAccount. Such a pod could impersonate an OpenSearch node, potentially joining an existing OpenSearch cluster and gaining access to read or modify its data.

    I am actively seeking a solution that prevents this scenario. Currently, I am exploring the feasibility of utilizing the UID of the root of the managing controllers (identified via ownerReferences) as the CN. In the case of OpenSearch, this would refer to the UID of the OpenSearchCluster, which is known to the operator and could be set as a trusted CN.

  9. moved this from Selected for Development to In Refinement in Stackable End-to-End Coordinationon Mar 23, 2026
  10. moved this to Refinement: In Progress in Stackable Engineeringon Mar 23, 2026
  11. moved this from Refinement: In Progress to Ready for Development in Stackable Engineeringon May 6, 2026
  12. moved this from In Refinement to In Progress in Stackable End-to-End Coordinationon May 12, 2026
  13. moved this from Ready for Development to Development: In Progress in Stackable Engineeringon May 12, 2026
  14. moved this from Development: In Progress to Development: Done in Stackable Engineeringon Jul 7, 2026
  15. siegfriedweber commented on Jul 7, 2026

    @siegfriedweber
    Member

    Release notes are in the linked pull requests.

  16. moved this from Development: Done to Acceptance: In Progress in Stackable Engineeringon Jul 16, 2026
  17. moved this from Acceptance: In Progress to Done in Stackable Engineeringon Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions