An open API service providing security vulnerability metadata for many open source software ecosystems.

GSA_kwCzR0hTQS03MzN2LXAzaDUtcXBxN84ABHLb

Moderate

GraphQL Armor Cost-Limit Plugin Bypass via Introspection Query Obfuscation

Affected Packages Affected Versions Fixed Versions
npm:@escape.tech/graphql-armor-cost-limit
PURL: pkg:npm/%40escape.tech%2Fgraphql-armor-cost-limit
< 2.4.2 2.4.2
3 Dependent packages
222 Dependent repositories
508,024 Downloads last month

Affected Version Ranges

All affected versions

1.0.0, 1.1.0, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.6.0, 1.6.1, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 2.0.0, 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.4.1

All unaffected versions

2.4.2, 2.4.3

Summary

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

Details

At the start of the computeComplexity function, we have the following check for ignoreIntrospection option:

    if (this.config.ignoreIntrospection && 'name' in node && node.name?.value === '__schema') {
      return 0;
    }

However, the node can be FieldNode | FragmentDefinitionNode | InlineFragmentNode | OperationDefinitionNode | FragmentSpreadNode

So, for example, sending the following query

query hello {
  books {
    title
  }
}

would create an OperationDefinitionNode with node.name.value == 'hello'

The proper way to handle this would be to check for the __schema field, which would create a FieldNode.

The fix is

    if (
      this.config.ignoreIntrospection &&
      'name' in node &&
      node.name?.value === '__schema' &&
      node.kind === Kind.FIELD
    ) {
      return 0;
    }

to assert that the node must be a FieldNode

PoC

query  {
  ...__schema
}

fragment __schema on Query {
  books {
    title
    author
  }
}
query __schema {
  books {
    title
    author
  }
}

Impact

Applications using GraphQL Armor Cost Limit plugin with ignoreIntrospection enabled.

Fix:

Fixed on 772. A quick patch would be to set ignoreIntrospection to false.

References: