You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In file: request.go, there is a function ReadEntity which handles HTTP request bodies. It looks for a suitable entity reader based on the Content-Type header and uses the reader for a default content type if no matching reader is found. It then uses that reader to read the request body into the provided entityPointer.
// ReadEntity checks the Accept header and reads the content into the entityPointer.func (r*Request) ReadEntity(entityPointerinterface{}) (errerror) {
contentType:=r.Request.Header.Get(HEADER_ContentType)
contentEncoding:=r.Request.Header.Get(HEADER_ContentEncoding)
// check if the request body needs decompressionifENCODING_GZIP==contentEncoding {
gzipReader:=currentCompressorProvider.AcquireGzipReader()
defercurrentCompressorProvider.ReleaseGzipReader(gzipReader)
gzipReader.Reset(r.Request.Body)
r.Request.Body=gzipReader
} elseifENCODING_DEFLATE==contentEncoding {
zlibReader, err:=zlib.NewReader(r.Request.Body)
iferr!=nil {
returnerr
}
r.Request.Body=zlibReader
}
// lookup the EntityReader, use defaultRequestContentType if needed and providedentityReader, ok:=entityAccessRegistry.accessorAt(contentType)
if!ok {
iflen(defaultRequestContentType) !=0 {
entityReader, ok=entityAccessRegistry.accessorAt(defaultRequestContentType)
}
if!ok {
returnNewError(http.StatusBadRequest, "Unable to unmarshal content of type:"+contentType)
}
}
returnentityReader.Read(r, entityPointer)
}
However the objects passed to ReadEntity are not validated to see if their fields hold appropriate values after deserialization. For example, in file: restful-resource-functions.go, the function postOne passes a Product object to ReadEntity for populating the objects's fields using data from the request body. But there is no subsequent content validation for the deserialized object.
func (pProductResource) postOne(req*restful.Request, resp*restful.Response) {
updatedProduct:=new(Product)
err:=req.ReadEntity(updatedProduct)
iferr!=nil { // bad requestresp.WriteErrorString(http.StatusBadRequest, err.Error())
return
}
log.Println("updating product with id:"+updatedProduct.Id)
}
This is a potential case of insecure deserialization.
This work is done by the security researchers from OpenRefactory and is supported by the Open Source Security Foundation (OpenSSF): Project Alpha-Omega. Alpha-Omega is a project partnering with open source software project maintainers to systematically find new, as-yet-undiscovered vulnerabilities in open source code - and get them fixed - to improve global software supply chain security.
The bug is found by running the iCR tool by OpenRefactory, Inc. and then manually triaging the results.
The text was updated successfully, but these errors were encountered:
@ZuhairORZaki thank you for sharing this information. My first impression is that this is not a bug and not a problem specific to go-restful as it uses standard Go SDK behavior. I have to take some time to see if and what I want to do about this issue.
Overview
In file: request.go, there is a function
ReadEntity
which handles HTTP request bodies. It looks for a suitable entity reader based on theContent-Type
header and uses the reader for a default content type if no matching reader is found. It then uses that reader to read the request body into the providedentityPointer
.However the objects passed to
ReadEntity
are not validated to see if their fields hold appropriate values after deserialization. For example, in file: restful-resource-functions.go, the functionpostOne
passes aProduct
object toReadEntity
for populating the objects's fields using data from the request body. But there is no subsequent content validation for the deserialized object.This is a potential case of insecure deserialization.
References
Insecure deserialization - Go
Sponsorship and Support:
This work is done by the security researchers from OpenRefactory and is supported by the Open Source Security Foundation (OpenSSF): Project Alpha-Omega. Alpha-Omega is a project partnering with open source software project maintainers to systematically find new, as-yet-undiscovered vulnerabilities in open source code - and get them fixed - to improve global software supply chain security.
The bug is found by running the iCR tool by OpenRefactory, Inc. and then manually triaging the results.
The text was updated successfully, but these errors were encountered: