UiPath Documentation
automation-suite
2.2510
true
Guía de instalación de Automation Suite en Linux
Importante :
Este contenido se ha localizado parcialmente a partir de un sistema de traducción automática. La localización de contenidos recién publicados puede tardar entre una y dos semanas en estar disponible.

Mitigación manual de Política de red de ArgoCD (GHSA-47m3-95c7-g2g8)

Soluciones para el acceso a la red no autenticado al servidor de repositorio de ArgoCD y Redis en Automation Suite, con un procedimiento manual de mitigación de PolíticaDeRed.

Descripción

Recientemente se publicó una vulnerabilidad que afecta al componente ArgoCD repo-server y ArgoCD no la ha corregido en este momento.

Se puede acceder a ArgoCD repo-server (puerto 8081) y ArgoCD Redis desde cualquier pod de la red del clúster, porque ninguna PolíticaDeRed restringe la entrada a estos componentes de forma predeterminada. Como resultado, cualquier pod dentro de la red del clúster puede conectarse a ellos directamente, ya que ArgoCD no requiere autenticación para estos componentes internos. Para obtener más información, consulta GHSA-47m3-95c7-g2g8.

Para mitigar el problema, debes aplicar manualmente la PolíticaDeRed descrita en la sección Solución de esta página.

Requisitos previos

  • Ejecuta este procedimiento desde un host con acceso kubectl al clúster.
  • El procedimiento asume el espacio de nombres predeterminado de Automation Suite argocd . Si ArgoCD utiliza un espacio de nombres diferente, establece ARGOCD_NS antes de ejecutar el script.
  • Esta mitigación se basa en la aplicación de Kubernetes NetworkPolicy. Los clústeres compatibles con Automation Suite utilizan una configuración CNI (Container Network Interface) compatible.

Solución

  1. Ejecuta el siguiente script. Detecta tu versión de ArgoCD y el modo Redis (independiente o de alta disponibilidad, HA) y aplica la PolíticaDeRed correspondiente automáticamente:

    export ARGOCD_NS="${ARGOCD_NS:-argocd}"
    export ARGOCD_RELEASE="$(kubectl -n "$ARGOCD_NS" get pod -l app.kubernetes.io/name=argocd-server -o jsonpath='{.items[0].metadata.labels.app\.kubernetes\.io/instance}')"
    
    test -n "$ARGOCD_RELEASE" || { echo "Cannot detect Argo CD Helm release"; exit 1; }
    
    if kubectl -n "$ARGOCD_NS" get pod -l "release=${ARGOCD_RELEASE},app=redis-ha-haproxy,component=haproxy" --no-headers 2>/dev/null | grep -q .; then
      REDIS_MODE=ha
    else
      REDIS_MODE=standalone
    fi
    
    echo "Argo CD namespace: $ARGOCD_NS"
    echo "Argo CD release: $ARGOCD_RELEASE"
    echo "Redis mode: $REDIS_MODE"
    
    cat <<EOF | kubectl apply -f -
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: argocd-repo-server-manual-mitigation
      namespace: ${ARGOCD_NS}
    spec:
      podSelector:
        matchLabels:
          app.kubernetes.io/name: argocd-repo-server
          app.kubernetes.io/instance: ${ARGOCD_RELEASE}
      policyTypes:
        - Ingress
      ingress:
        - from:
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-server
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-application-controller
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-applicationset-controller
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-notifications-controller
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
          ports:
            - protocol: TCP
              port: 8081
        - from:
            - namespaceSelector: {}
          ports:
            - protocol: TCP
              port: 8084
    EOF
    
    if [ "$REDIS_MODE" = "ha" ]; then
      cat <<EOF | kubectl apply -f -
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: argocd-redis-ha-server-manual-mitigation
      namespace: ${ARGOCD_NS}
    spec:
      podSelector:
        matchLabels:
          release: ${ARGOCD_RELEASE}
          app: redis-ha
      policyTypes:
        - Ingress
      ingress:
        - from:
            - podSelector:
                matchLabels:
                  release: ${ARGOCD_RELEASE}
                  app: redis-ha
            - podSelector:
                matchLabels:
                  release: ${ARGOCD_RELEASE}
                  app: redis-ha-haproxy
                  component: haproxy
          ports:
            - protocol: TCP
              port: 6379
            - protocol: TCP
              port: 26379
    ---
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: argocd-redis-ha-haproxy-manual-mitigation
      namespace: ${ARGOCD_NS}
    spec:
      podSelector:
        matchLabels:
          release: ${ARGOCD_RELEASE}
          app: redis-ha-haproxy
          component: haproxy
          app.kubernetes.io/name: argocd-redis-ha-haproxy
      policyTypes:
        - Ingress
      ingress:
        - from:
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-server
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-repo-server
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-application-controller
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
          ports:
            - protocol: TCP
              port: 6379
    EOF
    else
      cat <<EOF | kubectl apply -f -
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: argocd-redis-manual-mitigation
      namespace: ${ARGOCD_NS}
    spec:
      podSelector:
        matchLabels:
          app.kubernetes.io/name: argocd-redis
          app.kubernetes.io/instance: ${ARGOCD_RELEASE}
      policyTypes:
        - Ingress
      ingress:
        - from:
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-server
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-repo-server
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-application-controller
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
          ports:
            - protocol: TCP
              port: 6379
        - from:
            - namespaceSelector: {}
          ports:
            - protocol: TCP
              port: 9121
    EOF
    fi
    export ARGOCD_NS="${ARGOCD_NS:-argocd}"
    export ARGOCD_RELEASE="$(kubectl -n "$ARGOCD_NS" get pod -l app.kubernetes.io/name=argocd-server -o jsonpath='{.items[0].metadata.labels.app\.kubernetes\.io/instance}')"
    
    test -n "$ARGOCD_RELEASE" || { echo "Cannot detect Argo CD Helm release"; exit 1; }
    
    if kubectl -n "$ARGOCD_NS" get pod -l "release=${ARGOCD_RELEASE},app=redis-ha-haproxy,component=haproxy" --no-headers 2>/dev/null | grep -q .; then
      REDIS_MODE=ha
    else
      REDIS_MODE=standalone
    fi
    
    echo "Argo CD namespace: $ARGOCD_NS"
    echo "Argo CD release: $ARGOCD_RELEASE"
    echo "Redis mode: $REDIS_MODE"
    
    cat <<EOF | kubectl apply -f -
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: argocd-repo-server-manual-mitigation
      namespace: ${ARGOCD_NS}
    spec:
      podSelector:
        matchLabels:
          app.kubernetes.io/name: argocd-repo-server
          app.kubernetes.io/instance: ${ARGOCD_RELEASE}
      policyTypes:
        - Ingress
      ingress:
        - from:
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-server
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-application-controller
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-applicationset-controller
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-notifications-controller
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
          ports:
            - protocol: TCP
              port: 8081
        - from:
            - namespaceSelector: {}
          ports:
            - protocol: TCP
              port: 8084
    EOF
    
    if [ "$REDIS_MODE" = "ha" ]; then
      cat <<EOF | kubectl apply -f -
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: argocd-redis-ha-server-manual-mitigation
      namespace: ${ARGOCD_NS}
    spec:
      podSelector:
        matchLabels:
          release: ${ARGOCD_RELEASE}
          app: redis-ha
      policyTypes:
        - Ingress
      ingress:
        - from:
            - podSelector:
                matchLabels:
                  release: ${ARGOCD_RELEASE}
                  app: redis-ha
            - podSelector:
                matchLabels:
                  release: ${ARGOCD_RELEASE}
                  app: redis-ha-haproxy
                  component: haproxy
          ports:
            - protocol: TCP
              port: 6379
            - protocol: TCP
              port: 26379
    ---
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: argocd-redis-ha-haproxy-manual-mitigation
      namespace: ${ARGOCD_NS}
    spec:
      podSelector:
        matchLabels:
          release: ${ARGOCD_RELEASE}
          app: redis-ha-haproxy
          component: haproxy
          app.kubernetes.io/name: argocd-redis-ha-haproxy
      policyTypes:
        - Ingress
      ingress:
        - from:
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-server
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-repo-server
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-application-controller
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
          ports:
            - protocol: TCP
              port: 6379
    EOF
    else
      cat <<EOF | kubectl apply -f -
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: argocd-redis-manual-mitigation
      namespace: ${ARGOCD_NS}
    spec:
      podSelector:
        matchLabels:
          app.kubernetes.io/name: argocd-redis
          app.kubernetes.io/instance: ${ARGOCD_RELEASE}
      policyTypes:
        - Ingress
      ingress:
        - from:
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-server
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-repo-server
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
            - podSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-application-controller
                  app.kubernetes.io/instance: ${ARGOCD_RELEASE}
          ports:
            - protocol: TCP
              port: 6379
        - from:
            - namespaceSelector: {}
          ports:
            - protocol: TCP
              port: 9121
    EOF
    fi
    

Verificar

Ejecuta los siguientes comandos para confirmar que la mitigación se ha aplicado correctamente:

kubectl -n "$ARGOCD_NS" get networkpolicy
kubectl -n "$ARGOCD_NS" get pods
kubectl get applications.argoproj.io -A
kubectl -n "$ARGOCD_NS" get networkpolicy
kubectl -n "$ARGOCD_NS" get pods
kubectl get applications.argoproj.io -A

Confirma lo siguiente:

  • argocd-repo-server-manual-mitigation existe.
  • Para Redis HA, argocd-redis-ha-server-manual-mitigation y argocd-redis-ha-haproxy-manual-mitigation existen.
  • Para Redis independiente, argocd-redis-manual-mitigation existe.
  • Los pods de ArgoCD son Running o Completed.
  • Las aplicaciones de ArgoCD siguen siendo Synced y Healthy.

Confirmar mitigación

Ejecuta estas comprobaciones después de aplicar las políticas. Verifican que el tráfico de ArgoCD requerido sigue funcionando y que el tráfico no permitido está bloqueado.

  1. Ejecuta el siguiente script:

    export ARGOCD_NS="${ARGOCD_NS:-argocd}"
    export ARGOCD_RELEASE="${ARGOCD_RELEASE:-$(kubectl -n "$ARGOCD_NS" get pod -l app.kubernetes.io/name=argocd-server -o jsonpath='{.items[0].metadata.labels.app\.kubernetes\.io/instance}')}"
    
    if kubectl -n "$ARGOCD_NS" get pod -l "release=${ARGOCD_RELEASE},app=redis-ha-haproxy,component=haproxy" --no-headers 2>/dev/null | grep -q .; then
      REDIS_MODE=ha
    else
      REDIS_MODE=standalone
    fi
    
    SERVER_POD="$(kubectl -n "$ARGOCD_NS" get pod -l app.kubernetes.io/name=argocd-server -o jsonpath='{.items[0].metadata.name}')"
    APPSET_POD="$(kubectl -n "$ARGOCD_NS" get pod -l app.kubernetes.io/name=argocd-applicationset-controller -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)"
    FAILED_CHECKS=""
    
    tcp_check() {
      pod="$1"
      host="$2"
      port="$3"
      expected="$4"
      name="$5"
    
      code="$(kubectl -n "$ARGOCD_NS" exec "$pod" -- sh -c '
        host="$1"
        port="$2"
        if command -v nc >/dev/null 2>&1; then
          timeout 5 nc -z -w 3 "$host" "$port" >/dev/null 2>&1
          printf "%s\n" "$?"
        elif command -v bash >/dev/null 2>&1; then
          timeout 5 bash -c "</dev/tcp/${host}/${port}" >/dev/null 2>&1
          printf "%s\n" "$?"
        else
          printf "%s\n" "NO_TCP_TOOL"
        fi
      ' sh "$host" "$port" 2>/dev/null | tail -n 1)"
    
      if [ "$expected" = "allow" ] && [ "$code" = "0" ]; then
        return
      elif [ "$expected" = "deny" ] && [ "$code" != "0" ] && [ "$code" != "NO_TCP_TOOL" ] && [ -n "$code" ]; then
        return
      else
        FAILED_CHECKS="${FAILED_CHECKS}
    - ${name}: expected ${expected}, got exit code ${code}"
      fi
    }
    
    tcp_check "$SERVER_POD" argocd-repo-server 8081 allow "argocd-server to repo-server:8081"
    
    if [ "$REDIS_MODE" = "ha" ]; then
      HAPROXY_POD="$(kubectl -n "$ARGOCD_NS" get pod -l app=redis-ha-haproxy,component=haproxy -o jsonpath='{.items[0].metadata.name}')"
    
      tcp_check "$SERVER_POD" argocd-redis-ha-haproxy 6379 allow "argocd-server to redis-ha-haproxy:6379"
      tcp_check "$HAPROXY_POD" argocd-redis-ha 6379 allow "redis-ha-haproxy to redis-ha:6379"
      tcp_check "$HAPROXY_POD" argocd-repo-server 8081 deny "redis-ha-haproxy to repo-server:8081"
    
      if [ -n "$APPSET_POD" ]; then
        tcp_check "$APPSET_POD" argocd-redis-ha-haproxy 6379 deny "applicationset-controller to redis-ha-haproxy:6379"
      fi
    else
      REDIS_POD="$(kubectl -n "$ARGOCD_NS" get pod -l app.kubernetes.io/name=argocd-redis -o jsonpath='{.items[0].metadata.name}')"
    
      tcp_check "$SERVER_POD" argocd-redis 6379 allow "argocd-server to redis:6379"
      tcp_check "$REDIS_POD" argocd-repo-server 8081 deny "redis to repo-server:8081"
    
      if [ -n "$APPSET_POD" ]; then
        tcp_check "$APPSET_POD" argocd-redis 6379 deny "applicationset-controller to redis:6379"
      fi
    fi
    
    if [ -z "$FAILED_CHECKS" ]; then
      echo "MITIGATION CHECK: PASS"
    else
      echo "MITIGATION CHECK: FAIL"
      echo "$FAILED_CHECKS"
      exit 1
    fi
    export ARGOCD_NS="${ARGOCD_NS:-argocd}"
    export ARGOCD_RELEASE="${ARGOCD_RELEASE:-$(kubectl -n "$ARGOCD_NS" get pod -l app.kubernetes.io/name=argocd-server -o jsonpath='{.items[0].metadata.labels.app\.kubernetes\.io/instance}')}"
    
    if kubectl -n "$ARGOCD_NS" get pod -l "release=${ARGOCD_RELEASE},app=redis-ha-haproxy,component=haproxy" --no-headers 2>/dev/null | grep -q .; then
      REDIS_MODE=ha
    else
      REDIS_MODE=standalone
    fi
    
    SERVER_POD="$(kubectl -n "$ARGOCD_NS" get pod -l app.kubernetes.io/name=argocd-server -o jsonpath='{.items[0].metadata.name}')"
    APPSET_POD="$(kubectl -n "$ARGOCD_NS" get pod -l app.kubernetes.io/name=argocd-applicationset-controller -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)"
    FAILED_CHECKS=""
    
    tcp_check() {
      pod="$1"
      host="$2"
      port="$3"
      expected="$4"
      name="$5"
    
      code="$(kubectl -n "$ARGOCD_NS" exec "$pod" -- sh -c '
        host="$1"
        port="$2"
        if command -v nc >/dev/null 2>&1; then
          timeout 5 nc -z -w 3 "$host" "$port" >/dev/null 2>&1
          printf "%s\n" "$?"
        elif command -v bash >/dev/null 2>&1; then
          timeout 5 bash -c "</dev/tcp/${host}/${port}" >/dev/null 2>&1
          printf "%s\n" "$?"
        else
          printf "%s\n" "NO_TCP_TOOL"
        fi
      ' sh "$host" "$port" 2>/dev/null | tail -n 1)"
    
      if [ "$expected" = "allow" ] && [ "$code" = "0" ]; then
        return
      elif [ "$expected" = "deny" ] && [ "$code" != "0" ] && [ "$code" != "NO_TCP_TOOL" ] && [ -n "$code" ]; then
        return
      else
        FAILED_CHECKS="${FAILED_CHECKS}
    - ${name}: expected ${expected}, got exit code ${code}"
      fi
    }
    
    tcp_check "$SERVER_POD" argocd-repo-server 8081 allow "argocd-server to repo-server:8081"
    
    if [ "$REDIS_MODE" = "ha" ]; then
      HAPROXY_POD="$(kubectl -n "$ARGOCD_NS" get pod -l app=redis-ha-haproxy,component=haproxy -o jsonpath='{.items[0].metadata.name}')"
    
      tcp_check "$SERVER_POD" argocd-redis-ha-haproxy 6379 allow "argocd-server to redis-ha-haproxy:6379"
      tcp_check "$HAPROXY_POD" argocd-redis-ha 6379 allow "redis-ha-haproxy to redis-ha:6379"
      tcp_check "$HAPROXY_POD" argocd-repo-server 8081 deny "redis-ha-haproxy to repo-server:8081"
    
      if [ -n "$APPSET_POD" ]; then
        tcp_check "$APPSET_POD" argocd-redis-ha-haproxy 6379 deny "applicationset-controller to redis-ha-haproxy:6379"
      fi
    else
      REDIS_POD="$(kubectl -n "$ARGOCD_NS" get pod -l app.kubernetes.io/name=argocd-redis -o jsonpath='{.items[0].metadata.name}')"
    
      tcp_check "$SERVER_POD" argocd-redis 6379 allow "argocd-server to redis:6379"
      tcp_check "$REDIS_POD" argocd-repo-server 8081 deny "redis to repo-server:8081"
    
      if [ -n "$APPSET_POD" ]; then
        tcp_check "$APPSET_POD" argocd-redis 6379 deny "applicationset-controller to redis:6379"
      fi
    fi
    
    if [ -z "$FAILED_CHECKS" ]; then
      echo "MITIGATION CHECK: PASS"
    else
      echo "MITIGATION CHECK: FAIL"
      echo "$FAILED_CHECKS"
      exit 1
    fi
    

    Resultado esperado: MITIGATION CHECK: PASS

Reversión

Si es necesario, sigue los siguientes pasos para eliminar la mitigación:

  1. Elimina las políticas de mitigación manuales:

    kubectl -n "$ARGOCD_NS" delete networkpolicy \
      argocd-repo-server-manual-mitigation \
      argocd-redis-manual-mitigation \
      argocd-redis-ha-server-manual-mitigation \
      argocd-redis-ha-haproxy-manual-mitigation \
      --ignore-not-found
    kubectl -n "$ARGOCD_NS" delete networkpolicy \
      argocd-repo-server-manual-mitigation \
      argocd-redis-manual-mitigation \
      argocd-redis-ha-server-manual-mitigation \
      argocd-redis-ha-haproxy-manual-mitigation \
      --ignore-not-found
    
  2. Confirma que la reversión se ha completado correctamente:

    kubectl -n "$ARGOCD_NS" get networkpolicy
    kubectl -n "$ARGOCD_NS" get pods
    kubectl get applications.argoproj.io -A
    kubectl -n "$ARGOCD_NS" get networkpolicy
    kubectl -n "$ARGOCD_NS" get pods
    kubectl get applications.argoproj.io -A
    

    Confirma lo siguiente:

    • Se eliminan las políticas de mitigación manuales.
    • Los pods de ArgoCD permanecen Running o Completed.
    • Las aplicaciones de ArgoCD siguen siendo Synced y Healthy.

¿Te ha resultado útil esta página?

Conectar

¿Necesita ayuda? Soporte

¿Quiere aprender? UiPath Academy

¿Tiene alguna pregunta? Foro de UiPath

Manténgase actualizado