Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • L libtasn1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 9
    • Issues 9
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gnutlsgnutls
  • libtasn1
  • Issues
  • #32
You need to sign in or sign up before continuing.
Closed
Open
Issue created Feb 04, 2021 by David Trabish@davidtr1037

Out-of-bound access in ETYPE_OK

Description of problem:

The bound check in ETYPE_OK may lead to out-of-bound access.

Version of libtasn1 used:

4.16.0

Distributor of libtasn1 (e.g., Ubuntu, Fedora, RHEL)

Ubuntu

How reproducible:

#include <stdlib.h>
#include <stdio.h>
#include <libtasn1.h>

int main(int argc, char *argv[]) {
    unsigned int etype = 38;

    unsigned int str_len = 10;
    unsigned char *str = malloc(str_len);

    unsigned int tl_len = 10;
    unsigned char *tl = malloc(tl_len);

    asn1_encode_simple_der(etype, str, str_len, tl, &tl_len);
    
    return 0;
}

Steps to Reproduce:

  • Compile the program with -fsanitize=address,leak,undefined
  • Run

Actual results:

==23616==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000042e208 at pc 0x000000402854 bp 0x7fffe0995170 sp 0x7fffe0995160
READ of size 8 at 0x00000042e208 thread T0
    #0 0x402853 in asn1_encode_simple_der ../../libtasn1-4.16.0/lib/coding.c:218

Expected results:

The macro should do this check instead:

(etype) < _asn1_tags_size
Assignee
Assign to
Time tracking