Coder Social home page Coder Social logo

Comments (8)

mrdeep1 avatar mrdeep1 commented on August 17, 2024

@zambbo What is the value you are using for COAP_MAX_PDU_SIZE ? That #define disappeared back in 2017, and was replaced by COAP_DEFAULT_PDU_SIZE.

from libcoap.

zambbo avatar zambbo commented on August 17, 2024

oh, the #define COAP_MAX_PDU_SIZE 1152 is dropped. the value of COAP_MAX_PDU_SIZE is 1152

from libcoap.

mrdeep1 avatar mrdeep1 commented on August 17, 2024

OK. An issue is that coap_add_option(pdu, COAP_OPTION_URI_PORT, 8, data); is stating that the size of data is 8, when in reality it is 4.

from libcoap.

zambbo avatar zambbo commented on August 17, 2024

Yes, if the 3rd argument in coap_add_option function is greater than 4th argument buffer size, buffer overflow occurs in memcpy function in coap_opt_encode.

from libcoap.

mrdeep1 avatar mrdeep1 commented on August 17, 2024

OK, but is user error in what was passed to coap_add_option() that causes the overflow. coap_opt_encode() has no way of checking whether bad data is passed in or not.

from libcoap.

zambbo avatar zambbo commented on August 17, 2024

How about adding a length validation logic in coap_add_option to check for incorrect data being passed?

from libcoap.

mrdeep1 avatar mrdeep1 commented on August 17, 2024

Ignoring the requirement that the API does not change for now. Iā€™m not sure how you can check the size of a variable within the function, so this would need to be passed in, but again there could be user error. In your case, the 4 bytes following data are undefined, hence your found issue and I could have expected you to have used sizeof(data). But that would fail if data was a pointer.

from libcoap.

mrdeep1 avatar mrdeep1 commented on August 17, 2024

Any application call to a public libcoap API that provides (and states) a buffer size bigger than the actual size of the buffer, then any fuzzing logic should pick this up (which may be in a called sub-function). It is not a libcoap issue unless libcoap itself is doing this from its own internal data management.

As this example is for bad application provided data + data_size, I am closing this Issue. If however you do find an internal libcoap issue, then please raise a new Issue with the details to be able to reproduce it.

from libcoap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.