Skip to content

remap: bound the plugin argument arrays - #13633

Draft
brbzull0 wants to merge 1 commit into
apache:masterfrom
brbzull0:remap-plugin-arg-bounds
Draft

remap: bound the plugin argument arrays#13633
brbzull0 wants to merge 1 commit into
apache:masterfrom
brbzull0:remap-plugin-arg-bounds

Conversation

@brbzull0

@brbzull0 brbzull0 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

BUILD_TABLE_INFO sizes its argument arrays at BUILD_TABLE_MAX_ARGS, which is
2048 (include/proxy/http/remap/RemapConfig.h:31,62-63):

char *paramv[BUILD_TABLE_MAX_ARGS];
char *argv[BUILD_TABLE_MAX_ARGS];

remap_load_plugin() declared its own locals at half that:

const char *new_argv[1024];
char       *pargv[1024];

so a remap.config line carrying more than 1024 arguments overflowed them. In a
build with ink_assert enabled the existing assertion at
RemapConfig.cc:912 catches it and aborts; without it the writes simply run off
the end of two stack arrays.

Two further bounds issues in the same path:

  • The jump_to_argc copy loop was while (argv[i + jump_to_argc]), i.e. it
    walked until it found a null entry rather than stopping at argc.
  • remap_parse_config_bti() appended to bti->argv / bti->paramv inside the
    tokenizer loop but only compared against BUILD_TABLE_MAX_ARGS after the loop
    had finished, so bti->argc could pass 2048 before anything checked.

Change

  • Size new_argv and pargv from BUILD_TABLE_MAX_ARGS + 1, so they can hold
    the full limit plus the nullptr sentinel the copy loop reserves.
  • Bound the copy loop by argc and by countof(new_argv) - 1.
  • Reject an over-long line while tokenizing, with the file and line number in
    the error, instead of after the fact.

Test

Adds tests/gold_tests/remap/remap_plugin_argument_limits.test.py, with a
near-limit rule that must load and serve, and an over-limit rule that must be
rejected. There is no existing test in tests/gold_tests/remap/ covering the
argument count, and no collision with the 32 entries already there.

Confirmed it is a regression test: against unpatched RemapConfig.cc it fails
with

Fatal: RemapConfig.cc:912: failed assertion
`static_cast<unsigned>(argc) < countof(new_argv)` : 3

so traffic_server aborts while parsing remap.config. With the change the
test passes.

BUILD_TABLE_INFO sizes argv and paramv at BUILD_TABLE_MAX_ARGS (2048),
but remap_load_plugin() declared its new_argv and pargv locals at 1024,
so a remap.config line carrying more than 1024 arguments overflowed
them. The tokenizer in remap_parse_config_bti() also appended to
bti->argv without a bound, checking the limit only after the loop.

Size the locals from BUILD_TABLE_MAX_ARGS, bound the jump_to_argc copy
by argc rather than trusting a nullptr terminator, and reject an
over-long line while tokenizing.
@brbzull0 brbzull0 self-assigned this Sep 3, 2026
@brbzull0 brbzull0 added this to the 11.0.0 milestone Sep 3, 2026
@brbzull0

brbzull0 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

[approve ci ubuntu]

@brbzull0

brbzull0 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

[approve ci autest 2]

@brbzull0

brbzull0 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

[approve ci freebsd clang-analyzer autest 2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant