Skip to content

[BUG] Off-by-one buffer overflow in metadata label setter #141

Open

Description

@3453-315h

Bug Description

In src/service-maker/sources/core/src/metadata.cpp:320-323 (exposed through Python bindings at src/service-maker/sources/python/src/bindings/metadata.h:789):

The destination label buffer (obj_label in NvDsObjectMeta, defined in includes/nvdsmeta.h) is fixed at MAX_LABEL_SIZE bytes (128 bytes).

In the label setter:
When an input string of length $\ge 128$ is provided, the setter places a null terminator at index MAX_LABEL_SIZE ([128]), and uses an unbounded copy (strcpy). This writes 128 content bytes plus a terminating null byte (129 bytes total) into a 128-byte destination array, creating an off-by-one heap/buffer overflow.

Proposed Solution

Ensure string copying bounds the copy to sizeof(dest) - 1 bytes and guarantees termination inside the buffer:

--- a/src/service-maker/sources/core/src/metadata.cpp
+++ b/src/service-maker/sources/core/src/metadata.cpp
@@ -320,3 +320,4 @@
-    // bounds check / copy
-    strncpy(meta->obj_label, label.c_str(), sizeof(meta->obj_label) - 1);
-    meta->obj_label[sizeof(meta->obj_label) - 1] = '\0';

Activity

  1. self-assigned this
    on Nov 23, 2026
  2. fc-camel commented on Nov 23, 2026

    @fc-camel
    Collaborator

    @3453-315h Thank you for finding such potential security issue. We will check and get it fixed.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions