The vulnerability exists because the Prometheus metrics exporter, which is a Flask application, binds to all network interfaces (0.0.0.0) by default, exposing sensitive metrics. The root cause is the lack of configuration specifying a secure bind address for the exporter container.
The analysis of the provided patches pinpoints the newPrometheusExporterContainer function in pkg/ironic/containers.go as the source of the vulnerability. This function is responsible for defining the container specification for the Prometheus exporter. In the vulnerable versions, this function did not set the FLASK_RUN_HOST environment variable. The absence of this variable caused the underlying Flask application to use its default behavior of binding to 0.0.0.0.
The patch rectifies this by modifying newPrometheusExporterContainer to set the FLASK_RUN_HOST environment variable. Initially, it's hardcoded to 127.0.0.1 for security, and a subsequent commit makes this configurable through the Ironic CRD by adding a bindAddress field, which is then read by the newPrometheusExporterContainer function. Therefore, ironic.newPrometheusExporterContainer is the function that contains the vulnerability, as its failure to properly configure the container leads to the insecure exposure of the metrics endpoint.