Skip to content

Fix three high-impact Coverity defects#13030

Open
bryancall wants to merge 2 commits intoapache:masterfrom
bryancall:coverity-high-impact-fixes
Open

Fix three high-impact Coverity defects#13030
bryancall wants to merge 2 commits intoapache:masterfrom
bryancall:coverity-high-impact-fixes

Conversation

@bryancall
Copy link
Copy Markdown
Contributor

Summary

Fix three high-impact Coverity Scan defects (memory safety issues):

  • CID 1644226 (Use-after-free, High): plugins/slice/slice.cc - should_skip_this_obj() used urlstr in DEBUG_LOG after calling TSfree(). Moved TSfree() to after the last use of urlstr.

  • CID 1644298 (Out-of-bounds write, High): src/proxy/IPAllow.cc - When more than MAX_SUBJECTS (3) ACL subjects are configured, the parsing loop continued writing past the subjects[] array bounds. Added break after the error message.

  • CID 1644219 (Buffer not null-terminated, High): plugins/slice/server.cc - handleNextServerHeader() used strncpy() to copy etag and last-modified values without ensuring null termination. Replaced with memcpy() + explicit null terminator, and clamped lengths to buffer size to prevent overflow.

Test plan

  • CI passes
  • Verify slice plugin still works correctly with range requests
  • Verify IPAllow with > 3 configured subjects logs error and doesn't crash

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Addresses three high-impact Coverity-reported memory-safety defects in ATS core ACL parsing and the slice plugin.

Changes:

  • Prevent out-of-bounds writes in ACL subject parsing when more than MAX_SUBJECTS are configured.
  • Fix a use-after-free in slice by ensuring the effective URL buffer is freed only after its final use.
  • Ensure ETag / Last-Modified buffers in slice are bounded and explicitly NUL-terminated.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/proxy/IPAllow.cc Stops parsing when too many ACL subjects are provided to avoid writing past subjects[].
plugins/slice/slice.cc Moves TSfree(urlstr) to after the final logging/use to avoid UAF.
plugins/slice/server.cc Replaces strncpy() with bounded copy + explicit terminator for identifier headers to ensure safe strings.

@bryancall bryancall force-pushed the coverity-high-impact-fixes branch from 7fbe242 to 41b2ae5 Compare March 27, 2026 06:33
CID 1644226: Use-after-free in slice plugin. should_skip_this_obj()
used urlstr in DEBUG_LOG after calling TSfree(). Move TSfree() to
after the last use of urlstr.

CID 1644298: Out-of-bounds write in IpAllow constructor. When more
than MAX_SUBJECTS ACL subjects are configured, the loop continued
writing to subjects[] past the array bounds. Add break after the
error message.

CID 1644219: Buffer not null-terminated in slice plugin.
handleNextServerHeader() used strncpy() to copy etag and
last-modified values without ensuring null termination. Replace
with memcpy() + explicit null terminator, and clamp lengths to
buffer size.
@bryancall bryancall force-pushed the coverity-high-impact-fixes branch 2 times, most recently from f491e3e to 00955c7 Compare March 27, 2026 07:17
Add ip_allow_subjects.test.py: Verifies that configuring more than
MAX_SUBJECTS (3) ACL subjects logs an error and does not crash, and
that exactly MAX_SUBJECTS works without error.

Add slice_long_etag.test.py: Verifies the slice plugin handles long
ETag values (4000 chars) without crashing when copying between
internal buffers during multi-block range requests.
@bryancall bryancall force-pushed the coverity-high-impact-fixes branch from 00955c7 to 59d7b0d Compare March 27, 2026 07:27
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.

2 participants