<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>358593</bug_id>
          
          <creation_ts>2016-01-26 15:33:08 +0000</creation_ts>
          <short_desc>kdeinit5 create /tmp/xauth-xxx-_y with inappropriate permission.</short_desc>
          <delta_ts>2016-06-22 11:10:49 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>Frameworks and Libraries</classification>
          <product>frameworks-kinit</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>Arch Linux</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="taro yamada">archer_ame</reporter>
          <assigned_to name="David Faure">faure</assigned_to>
          <cc>aacid</cc>
    
    <cc>Davidl.Rumley</cc>
    
    <cc>kdelibs-bugs-null</cc>
    
    <cc>rdieter</cc>
    
    <cc>stupor_scurvy343</cc>
    
    <cc>thoger</cc>
          
          <cf_commitlink>http://commits.kde.org/kinit/dece8fd89979cd1a86c03bcaceef6e9221e8d8cd</cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1572749</commentid>
    <comment_count>0</comment_count>
    <who name="taro yamada">archer_ame</who>
    <bug_when>2016-01-26 15:33:08 +0000</bug_when>
    <thetext>I&apos;m sorry if my English is hard to understand.

kdeinit5 create /tmp/xauth-xxx-_y with inappropriate permission, 644.
I think it should be 600.

---affected system---
Distro : ArchLinux
Qt version : 5.5.1 (I&apos;m sorry, I haven&apos;t check the other versions on Arch.)
KDE version : 5.18.0 (The same as above)
------

---not affected system---
Distro : Kubuntu 15.10 LiveCD
Qt version : 5.4.2
KDE version : 5.15.0
------



Reproducible: Always

Steps to Reproduce:
1. Just login to plasma5. (I tried sddm and startx.)

Actual Results:  
 The permission of /tmp/xauth-xxx-_y is 644.

Expected Results:  
The permission of /tmp/xauth-xxx-_y should be 600.

I&apos;m newbie but I tried to read the source for my study.
I changed near the line 1536 of kinit-5.18.0/src/kdeinit/kinit.cpp.
---before---
if (!xauthfrom.open(QFile::ReadOnly) || !xauthfile.open(QFile::WriteOnly)
    || xauthfile.write(xauthfrom.readAll()) != xauthfrom.size() || !xauthfile.commit()) {
------
to
---after---
if (!xauthfrom.open(QFile::ReadOnly) || !xauthfile.open(QFile::WriteOnly) || !xauthfile.setPermissions( QFile::Permissions( QFile::ReadOwner | QFile::WriteOwner ) )
     || xauthfile.write(xauthfrom.readAll()) != xauthfrom.size() || !xauthfile.commit()) {
------

And remove /tmp/xauth-xxx-_y and relogin, then the permission become 600.
I don&apos;t have enough ‎knowledge, so I can&apos;t determine this is valid solution or not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1595056</commentid>
    <comment_count>1</comment_count>
    <who name="Christoph Feck">cfeck</who>
    <bug_when>2016-05-17 12:16:16 +0000</bug_when>
    <thetext>*** Bug 363140 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1595134</commentid>
    <comment_count>2</comment_count>
    <who name="Albert Astals Cid">aacid</who>
    <bug_when>2016-05-17 21:33:43 +0000</bug_when>
    <thetext>*** Bug 363140 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1595140</commentid>
    <comment_count>3</comment_count>
    <who name="Albert Astals Cid">aacid</who>
    <bug_when>2016-05-17 22:09:06 +0000</bug_when>
    <thetext>Git commit dece8fd89979cd1a86c03bcaceef6e9221e8d8cd by Albert Astals Cid, on behalf of taro yamada.
Committed on 17/05/2016 at 22:08.
Pushed by aacid into branch &apos;master&apos;.

Fix permissions of /tmp/xauth-xxx-_y

M  +1    -0    src/kdeinit/kinit.cpp

http://commits.kde.org/kinit/dece8fd89979cd1a86c03bcaceef6e9221e8d8cd</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1595172</commentid>
    <comment_count>4</comment_count>
    <who name="Tomas Hoger">thoger</who>
    <bug_when>2016-05-18 08:29:40 +0000</bug_when>
    <thetext>Ain&apos;t this fix racy?  The file is first created as world readable, and later chmod-ed to expected permissions, leaving a (small) window during which the file can be opened by anyone.

Also this looks like a symptom of a larger problem.  Previously, the xauth file was stored in the /tmp/kde-$username directory with safe permissions (700):

https://userbase.kde.org/KDE_System_Administration/KDE_Filesystem_Hierarchy#Temporary_Files

That directory does not seem to be created any more.  Other programs that previously created temporary files with world-readable permissions inside the safe directory may also be affected if they now use /tmp directly instead.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1595635</commentid>
    <comment_count>5</comment_count>
    <who name="Albert Astals Cid">aacid</who>
    <bug_when>2016-05-19 22:06:55 +0000</bug_when>
    <thetext>(In reply to Tomas Hoger from comment #4)
&gt; Ain&apos;t this fix racy?  The file is first created as world readable, and later
&gt; chmod-ed to expected permissions, leaving a (small) window during which the
&gt; file can be opened by anyone.

Yes it is a bit racy, at this point it is the best mitigation *I* can offer, i am trying to get the people that know how this works to provide a better solution.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1595945</commentid>
    <comment_count>6</comment_count>
    <who name="Albert Astals Cid">aacid</who>
    <bug_when>2016-05-21 16:04:31 +0000</bug_when>
    <thetext>Fixed again with umask use</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1596198</commentid>
    <comment_count>7</comment_count>
    <who name="Tomas Hoger">thoger</who>
    <bug_when>2016-05-23 08:46:11 +0000</bug_when>
    <thetext>Adding the link to the umask fix, as it was not linked here automatically.

https://quickgit.kde.org/?p=kinit.git&amp;a=commitdiff&amp;h=72f3702dbe6cf15c06dc13da2c99c864e9022a58</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>