From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from weasel.tulip.relay.mailchannels.net (weasel.tulip.relay.mailchannels.net [23.83.218.247]) by sourceware.org (Postfix) with ESMTPS id 1E8A6385840C for ; Wed, 6 Sep 2023 11:23:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E8A6385840C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 81AC97A10C2; Wed, 6 Sep 2023 11:23:10 +0000 (UTC) Received: from pdx1-sub0-mail-a265.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0AB6A7A1491; Wed, 6 Sep 2023 11:23:10 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1693999390; a=rsa-sha256; cv=none; b=Z6i9/Eu3YHh5Jc+nXLUkQUFo855mTvFcGISX+QL6ZMZLm8xbyh+6TkSHNsOGsvJXRtNqaO /LqigQKlGh96ttb8I8lZujzMCnzY7UUGMX0zH9+oxMqiTQfs+Zn+eRg2ta0qbH6Ej/tp0x LGYUKV/gMUxV2BLxId+V65JcRALCEZBiQg/a/bN2/OTtlTb9DWYtBooFFxoTnv2byGwLtK fz3QE5QWrRdkJfWUl2LgD79qjFAP+N6nKj9XY6jsMik8QWikwqOCxDE9TuP128ziFDr9C1 Jbn6f04oxzhZr/pa9WJZeopoYhWdSQZEvKjKTdoEFnRM97olX9Cj/y/5GVcnPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1693999390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dP3IAYtFLHlSR+LMq3kZ8MtY/Ays8JjudPA0MH8/1yE=; b=Glsdvuifw/IlFqZ5p9VQVIZU6qCeFl/eWUzupy4x2Z1U5wWhf5PXip7r5zxNI10Bw50lFH doIskMUU4Ge0/msytkxCK6l2ZcTOw9PqkemcQ7Seus81AwOw08K8R6HslOfQ/qJ+a/h56a eZ2iYDPEQsCS+yx/2J04BQD+0cKmyEp2ewN3zOYk8V8GIFpYZK5vsjmWbetvjHb1saUkSm 7oi8g00gKlrG1Vn7NQFms0xPBLxq2wmeOVZEUYcq9tTAwmGHe5+MpWdYbmX9dw2qXqsrtH g7usw4YpvzR03i91Ak3Gtk3zaN4DzWJmut72t/w3Nx8C9qy31V2skguI6p9slw== ARC-Authentication-Results: i=1; rspamd-bfd6864c7-l86vk; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Chief-Vacuous: 0a7d79a773edd385_1693999390364_2843256293 X-MC-Loop-Signature: 1693999390364:3613441142 X-MC-Ingress-Time: 1693999390363 Received: from pdx1-sub0-mail-a265.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.117.184.116 (trex/6.9.1); Wed, 06 Sep 2023 11:23:10 +0000 Received: from [192.168.0.182] (bras-vprn-toroon4834w-lp130-02-142-113-138-41.dsl.bell.ca [142.113.138.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a265.dreamhost.com (Postfix) with ESMTPSA id 4Rgg3K403rz2Q; Wed, 6 Sep 2023 04:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1693999389; bh=dP3IAYtFLHlSR+LMq3kZ8MtY/Ays8JjudPA0MH8/1yE=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=e/xzs7iuCDzS6P1TmXL9m5xrHjxAjhVMVJGk1JA+M3HlFtTETP+LZ1N8cznRCPVzX 7xpmxBx+Vky9QOwx28X2ICue4ldoL7lHuNAo/teRSEU1QRyR+7ZDOfYqPYNX9ibvWD aOOaCAzY7zIYDXgC8cZ0BSZ0XpAYUS7v+JI1KjM2w2P4KUng/bBjfqjCvyXgG+RRJ3 GisOJklg2i/ZnAqC6SxN1ZG7kUGK/xWwTjbLJht2/uscKnN7gBjeC1TtHZucRwqnfT 9kUSbBLDmWuGmEozZokY4Css0rl68LGTObG2dOrMbfXR2H8L80V+FQS21+gnufY+CY J6YnkUoO946zg== Message-ID: Date: Wed, 6 Sep 2023 07:23:08 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [RFC] GCC Security policy Content-Language: en-US To: David Edelsohn , GCC Patches Cc: Carlos O'Donell References: From: Siddhesh Poyarekar In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3030.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_ASCII_DIVIDERS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello folks, Here's v3 of the top part of the security policy. Hopefully this addresses all concerns raised so far. Thanks, Sid What is a GCC security bug? =========================== A security bug is one that threatens the security of a system or network, or might compromise the security of data stored on it. In the context of GCC there are multiple ways in which this might happen and they're detailed below. Compiler drivers, programs, libgccjit and support libraries ----------------------------------------------------------- The compiler driver processes source code, invokes other programs such as the assembler and linker and generates the output result, which may be assembly code or machine code. Compiling untrusted sources can result in arbitrary code execution and unconstrained resource consumption in the compiler. As a result, compilation of such code should be done inside a sandboxed environment to ensure that it does not compromise the development environment. The libgccjit library can, despite the name, be used both for ahead-of-time compilation and for just-in-compilation. In both cases it can be used to translate input representations (such as source code) in the application context; in the latter case the generated code is also run in the application context. Limitations that apply to the compiler driver, apply here too in terms of sanitizing inputs and it is recommended that both the compilation *and* execution context of the code are appropriately sandboxed to contain the effects of any bugs in libgccjit, the application code using it, or its generated code to the sandboxed environment. Support libraries such as libiberty, libcc1 libvtv and libcpp have been developed separately to share code with other tools such as binutils and gdb. These libraries again have similar challenges to compiler drivers. While they are expected to be robust against arbitrary input, they should only be used with trusted inputs. Libraries such as zlib that bundled into GCC to build it will be treated the same as the compiler drivers and programs as far as security coverage is concerned. However if you find an issue in these libraries independent of their use in GCC, you should reach out to their upstream projects to report them. As a result, the only case for a potential security issue in the compiler is when it generates vulnerable application code for trusted input source code that is conforming to the relevant programming standard or extensions documented as supported by GCC and the algorithm expressed in the source code does not have the vulnerability. The output application code could be considered vulnerable if it produces an actual vulnerability in the target application, specifically in the following cases: - The application dereferences an invalid memory location despite the application sources being valid. - The application reads from or writes to a valid but incorrect memory location, resulting in an information integrity issue or an information leak. - The application ends up running in an infinite loop or with severe degradation in performance despite the input sources having no such issue, resulting in a Denial of Service. Note that correct but non-performant code is not a security issue candidate, this only applies to incorrect code that may result in performance degradation severe enough to amount to a denial of service. - The application crashes due to the generated incorrect code, resulting in a Denial of Service. Language runtime libraries -------------------------- GCC also builds and distributes libraries that are intended to be used widely to implement runtime support for various programming languages. These include the following: * libada * libatomic * libbacktrace * libcc1 * libcody * libcpp * libdecnumber * libffi * libgcc * libgfortran * libgm2 * libgo * libgomp * libiberty * libitm * libobjc * libphobos * libquadmath * libsanitizer * libssp * libstdc++ These libraries are intended to be used in arbitrary contexts and as a result, bugs in these libraries may be evaluated for security impact. However, some of these libraries, e.g. libgo, libphobos, etc. are not maintained in the GCC project, due to which the GCC project may not be the correct point of contact for them. You are encouraged to look at README files within those library directories to locate the canonical security contact point for those projects and include them in the report. Once the issue is fixed in the upstream project, the fix will be synced into GCC in a future release. Most security vulnerabilities in these runtime libraries arise when an application uses functionality in a specific way. As a result, not all bugs qualify as security relevant. The following guidelines can help with the decision: - Buffer overflows and integer overflows should be treated as security issues if it is conceivable that the data triggering them can come from an untrusted source. - Bugs that cause memory corruption which is likely exploitable should be treated as security bugs. - Information disclosure can be security bugs, especially if exposure through applications can be determined. - Memory leaks and races are security bugs if they cause service breakage. - Stack overflow through unbounded alloca calls or variable-length arrays are security bugs if it is conceivable that the data triggering the overflow could come from an untrusted source. - Stack overflow through deep recursion and other crashes are security bugs if they cause service breakage. - Bugs that cripple the whole system (so that it doesn't even boot or does not run most applications) are not security bugs because they will not be exploitable in practice, due to general system instability. Diagnostic libraries -------------------- The sanitizer library bundled in GCC is intended to be used in diagnostic cases and not intended for use in sensitive environments. As a result, bugs in the sanitizer will not be considered security sensitive. GCC plugins ----------- It should be noted that GCC may execute arbitrary code loaded by a user through the GCC plugin mechanism or through system preloading mechanism. Such custom code should be vetted by the user for safety as bugs exposed through such code will not be considered security issues. Security features implemented in GCC ------------------------------------ GCC implements a number of security features that reduce the impact of security issues in applications, such as -fstack-protector, -fstack-clash-protection, _FORTIFY_SOURCE and so on. A failure in these features functioning perfectly in all situations is not a security issue in itself since they're dependent on heuristics and may not always have full coverage for protection. Similarly, GCC may transform code in a way that the correctness of the expressed algorithm is preserved, but supplementary properties that are not specifically expressible in a high-level language are not preserved. Examples of such supplementary properties include absence of sensitive data in the program's address space after an attempt to wipe it, or data-independent timing of code. When the source code attempts to express such properties, failure to preserve them in resulting machine code is not a security issue in GCC.