Skip to content

suspicious request 'compression' #2497

@rub1q

Description

@rub1q

Hi,

At the moment we use netopeer2 (ver. 2.2.13), libnetconf (ver. 3.5.5) and libyang (ver. 2.46.3) and recently we faced with the problem of huge RAM usage by netopeer2-server process when sending large requests (100mb - 1gb). So we decided to update our stack to the latest versions and check how it works.

We use the following yang module for our tests:

module buffer-attack-module {
  yang-version 1.1;
  namespace "urn:abc:buffer-attack-module";
  prefix buffer-attack-module;

  rpc buffer-attack {
    input {
      leaf config {
        type string {
          length "0..4000000000";
        }
        mandatory true;
      }
    }
    output {
      leaf status-msg {
        type string;
      }
    }
  }
}

The request file is generating randomly with specified size and looks like:

<buffer-attack xmlns="urn:abc:buffer-attack-module">
<config>
gMn8MVoj6o4dDJYEqKZjhrJVBsxWW8sTD4del9l3CZI6rVYvS6nzTDqGHDNg33ljUj3letf6UhWzPaIIZzOPwlWkQYrxgHSprdTYMPEsU4gEqEpNrZFmvNMpqjFMBehk8BIL7ayT
</config>
</buffer-attack>

On the latest libyang version (4.2.2) we noticed that libyang 'compresses' a large requests (> 500Mb). For example:

yanglint -f xml -t rpc modules/buffer-attack-module@2018-02-14.yang req_1gb.xml | wc -c
536870942 # ~537Mb (expect 1Gb)

wc -c req_1gb.xml
1073741851 req_1gb.xml

Meanwhile, for the 100Mb file there is no 'compression':

yanglint -f xml -t rpc modules/buffer-attack-module@2018-02-14.yang req_100mb.xml | wc -c
104857630

wc -c req_100mb.xml 
104857627 req_100mb.xml

And it looks very weird.

If we diff two files (our request and yanglint result) we will see that the first 200 characters are same, but the last 200 differ:

diff -u <(head -c 200 req_1gb.xml) <(head -c 200 abc.txt)
--- /dev/fd/63  2026-03-18 11:05:17.774955432 +0300
+++ /dev/fd/62  2026-03-18 11:05:17.775955460 +0300
@@ -1,3 +1,3 @@
 <buffer-attack xmlns="urn:abc:buffer-attack-module">
-<config>
-gMn8MVoj6o4dDJYEqKZjhrJVBsxWW8sTD4del9l3CZI6rVYvS6nzTDqGHDNg33ljUj3letf6UhWzPaIIZzOPwlWkQYrxgHSprdTYMPEsU4gEqEpNrZFmvNMpqjFMBehk8BIL7ayT
\ No newline at end of file
+  <config>
+gMn8MVoj6o4dDJYEqKZjhrJVBsxWW8sTD4del9l3CZI6rVYvS6nzTDqGHDNg33ljUj3letf6UhWzPaIIZzOPwlWkQYrxgHSprdTYMPEsU4gEqEpNrZFmvNMpqjFMBehk8BIL7a
\ No newline at end of file


diff -u <(tail -c 200 req_1gb.xml) <(tail -c 200 abc.txt)
--- /dev/fd/63  2026-03-18 11:05:20.431029722 +0300
+++ /dev/fd/62  2026-03-18 11:05:20.427029610 +0300
@@ -1,3 +1,2 @@
-otLr0xC0rLYgUopkZS7UG0N3hZFyT3y8UI9paR5SFHsEtVaU7Gk9mR7NfawrZM1019VzZpX3LAPylXcxDdWI7Oyj7hlZe4ikQxvIAhsaCpRENQRbcaeFr8FMWc6DcgZ8mN9YHRM4A2pLaAV9r7OhWxw5c1FvxXyWipZykKLhoilPt
-</config>
-</buffer-attack>
\ No newline at end of file
+4RhiJvTFHERVmRI52YICsSlyjsbSxUc2dbRhB6f6WS4tyzAzMNJIifxvVawuu184ETt83BAqakK7NC4tLzGIEmdzRUeF9HxOrr0uj2L7WJyeBac0y4YDxrGOJ1JTU1VuuqAR1rp1z6koDTAWMWTGTkKXd7Ry6hZcEi1ZY6h7fRbu2</config>
+</buffer-attack>

It looks like libyang just cut the request content in the middle and add enclosed tags.

Can you explain please why this happens?

Metadata

Metadata

Assignees

No one assigned

    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