portainer: YAML Issue: "ReferenceError: Excessive alias count indicates a resource exhaustion attack"

Bug description Portainer no longer appears to support compose files with 100+ aliases in the YAML.
This worked in an earlier version (1.21.0) with no issue.

Expected behavior There should either be a much higher limit, or not limit.

Portainer Logs There is an error in the yaml syntax: ReferenceError: Excessive alias count indicates a resource exhaustion attack

Steps to reproduce the issue: Try and deploy this (duplicate services x25 times to hit limit):

version: '3.8'

# Yaml defaults
x-deploy-worker: &DEPLOY_WORKER
  mode: replicated
  replicas: 1
  update_config:
    parallelism: 1
    delay: 10s
    failure_action: rollback
    monitor: 30s
    order: start-first

  placement:
    constraints:
      - node.role == worker

x-hosts: &HOSTS
  - "example1:1.1.1.1"
  - "example2:2.2.2.2"

x-environment: &ENVIRONMENT
  HTTP_PROXY:  http://proxy:3128
  HTTPS_PROXY: http://proxy:3128

x-command: &COMMAND
  - tail
  - -f
  - /dev/null

services:
  # duplicate this block 25x times to get 100+ aliases
  test-xxx:
    image: alpine:3.13

    deploy:      *DEPLOY_WORKER
    extra_hosts: *HOSTS
    environment: *ENVIRONMENT

    command: *COMMAND

Technical details:

  • Portainer version: 2.9.3
  • Docker version (managed by Portainer): 20.10.8

Additional context The YAML library appears to have added this limitation in one of the recent releases via the maxAliasCount setting. Should be possible to set this to -1 during the validation to remove the limit.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 22 (5 by maintainers)

Most upvoted comments

We’re less concerned about external attackers (for the reasons outlined above) and more worried about users inadvertently triggering this themselves, resulting in a bad experience. We have a wide range of experience levels across our user base, and part of our goal with Portainer is to make things easier for users that don’t necessarily know all the ins and outs of how things work. We’d rather put some sort of limits in place to protect users from themselves than just leave it open and have users either crash their browser or worse, without understanding what has happened. We feel 10,000 is a sensible middle ground here.

Not supporting aliases at all, which is the current state, is definitely not what we want and that is 100% a bug. Inadvertently this issue became one that slipped through the cracks for various reasons, but it’s back on our radar now and we’re including a fix in our next release (2.21) that will set the limit to 10k.

Even if someone copypasted a malicious (or just heavy) YAML without thinking, the worst thing that could happen is a browser tab crashing.

Running a malicious image is a much greater risk for users, yet I see no discussions going on for years about adding a hardcoded allowlist.

Hey! We have some questions around this and hope to get community feedback

Purpose Behind Extensive Alias Use: Can you share the rationale for utilizing a high number of aliases in your setup? Are there specific challenges you’re aiming to address with this approach?

Alternatives to Alias Utilization: Have you considered or employed any alternatives to managing configurations without relying heavily on aliases? If so, what alternatives have you explored, and what has been your experience?

Extent of Alias Usage: How critical is the current limit on aliases to your operations? Would increasing the limit to let’s say 110 sufficiently meet your needs, or do you foresee a need for even more?

Usage Context: Is the extensive use of aliases specific to one environment, or is it a common practice across multiple setups you manage? Could you elaborate on the context?

Hey! We have some questions around this and hope to get community feedback

Purpose Behind Extensive Alias Use: Can you share the rationale for utilizing a high number of aliases in your setup? Are there specific challenges you’re aiming to address with this approach?

Alternatives to Alias Utilization: Have you considered or employed any alternatives to managing configurations without relying heavily on aliases? If so, what alternatives have you explored, and what has been your experience?

Extent of Alias Usage: How critical is the current limit on aliases to your operations? Would increasing the limit to let’s say 110 sufficiently meet your needs, or do you foresee a need for even more?

Usage Context: Is the extensive use of aliases specific to one environment, or is it a common practice across multiple setups you manage? Could you elaborate on the context?

I want to deploy Sentry with its compose file. They rely heavily on aliases. I can’t just rewrite the whole damn file.

There is already a PR that says to fix the issue. Why not just hit the merge button?

If you think merging this PR would result in breaking changes, please be transparent and let @Daniel-Marynicz work on a PR that doesn’t. Issues that have been open for years are a clear fuck you to the community. Why bother contributing if you don’t get feedback?

This is really frustrating…

@Nick-Portainer Example with 53 aliases. https://github.com/Daniel-Marynicz/yaml-parse-test

To count aliases you can use a command like grep "<<" example.yaml | wc -l.

But YAML.parse counts ~440 aliases probably by recursive algorithms.

And this example parses in only ~100ms. To kill the portainer, you’d probably have to have a few thousand in there and still fire off Yaml.parse in a loop. And docker does not limit such things at all. That’s why these aliases were invented, to use them.

I use aliases in yaml to avoid unnecessarily repeating certain parts of yaml and to make it easier to edit later.

This is what you do when programming in the go language. How would you feel if a limit of 100 functions in go was introduced from tomorrow.

The alternative is to remove the aliases which will then make editing very difficult and the yaml will be several times larger.

As above, this was resolved in 2.21.