Skip to content

rimage: insecure data handling #258

@plbossart

Description

@plbossart

Coverity reports the following issue

46        /* read in sections */
   	3. tainted_data_argument: Calling function fread taints argument section.
 47        count = fread(section, sizeof(Elf32_Shdr), hdr->e_shnum, module->fd);
   	4. Condition count != hdr->e_shnum, taking false branch.
 48        if (count != hdr->e_shnum) {
 49                fprintf(stderr, "error: failed to read %s section header %d\n",
 50                        module->elf_file, -errno);
 51                return -errno;
 52        }
 53
 54        /* read in strings */
   	
CID 313455 (#1 of 2): Untrusted value as argument (TAINTED_SCALAR)
5. tainted_data: Passing tainted variable section[hdr->e_shstrndx].sh_size to a tainted sink.
 55        module->strings = calloc(1, section[hdr->e_shstrndx].sh_size);

313455 Untrusted value as argument
The argument could be controlled by an attacker, who could invoke the function with arbitrary values (for example, a very high or negative buffer size).

In elf_read_sections: An unscrutinized value from an untrusted source used as argument to a function (for example, a buffer size) (CWE-20)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions