Skip to contentSkip to conversation

vnc: disable VNC password authentication (security type 2) when in FIPS mode

PATCH Superseded Paul Moore 6 participants 13 messages May 1, 2012 – May 2, 2012

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Paul Moore

author
#0 lore raw

PATCH 1/1 vnc: disable VNC password authentication (security type 2) when in FIPS mode

FIPS 140-2 requires disabling certain ciphers, including DES, which is used by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when the host system is operating in FIPS mode.

This patch causes qemu to emits a syslog entry indicating that VNC password auth is disabled when it detects the host is running in FIPS mode, and unless a VNC password was specified on the command line it continues normally. However, if a VNC password was given on the command line, qemu fails with an error message to stderr explaining that that VNC password auth is not allowed in FIPS mode.

---
 qemu-doc.texi |    8 +++++---
 ui/vnc.c      |   32 ++++++++++++++++++++++++++++++++
 ui/vnc.h      |    1 +
 3 files changed, 38 insertions(+), 3 deletions(-)
qemu-doc.texi +5 -3
index e5d7ac4..f9b113e 100644
@@ -1124,9 +1124,11 @@ the protocol limits passwords to 8 characters it should not be considered
 to provide high security. The password can be fairly easily brute-forced by
 a client making repeat connections. For this reason, a VNC server using password
 authentication should be restricted to only listen on the loopback interface
-or UNIX domain sockets. Password authentication is requested with the @code{password}
-option, and then once QEMU is running the password is set with the monitor. Until
-the monitor is used to set the password all clients will be rejected.
+or UNIX domain sockets. Password authentication is not supported when operating
+in FIPS 140-2 compliance mode as it requires the use of the DES cipher. Password
+authentication is requested with the @code{password} option, and then once QEMU
+is running the password is set with the monitor. Until the monitor is used to
+set the password all clients will be rejected.
 
 @example
 qemu [...OPTIONS...] -vnc :1,password -monitor stdio
ui/vnc.c +32 -0
index deb9ecd..620791e 100644
@@ -32,6 +32,7 @@
 #include "acl.h"
 #include "qemu-objects.h"
 #include "qmp-commands.h"
+#include <syslog.h>
 
 #define VNC_REFRESH_INTERVAL_BASE 30
 #define VNC_REFRESH_INTERVAL_INC  50
@@ -48,6 +49,24 @@ static DisplayChangeListener *dcl;
 static int vnc_cursor_define(VncState *vs);
 static void vnc_release_modifiers(VncState *vs);
 
+static int fips_enabled(void)
+{
+    int enabled = 0;
+    char value;
+    FILE *fds;
+
+    fds = fopen("/proc/sys/crypto/fips_enabled", "r");
+    if (fds == NULL) {
+        return 0;
+    }
+    if (fread(&value, sizeof(value), 1, fds) == 1 && value == '1') {
+        enabled = 1;
+    }
+    fclose(fds);
+
+    return enabled;
+}
+
 static void vnc_set_share_mode(VncState *vs, VncShareMode mode)
 {
 #ifdef _VNC_DEBUG
@@ -2748,6 +2767,12 @@ void vnc_display_init(DisplayState *ds)
     dcl->idle = 1;
     vnc_display = vs;
 
+    vs->fips = fips_enabled();
+    VNC_DEBUG("FIPS mode %s\n", (vs->fips ? "enabled" : "disabled"));
+    if (vs->fips) {
+        syslog(LOG_NOTICE, "Disabling VNC password auth due to FIPS mode\n");
+    }
+
     vs->lsock = -1;
 
     vs->ds = ds;
@@ -2892,6 +2917,13 @@ int vnc_display_open(DisplayState *ds, const char *display)
     while ((options = strchr(options, ','))) {
         options++;
         if (strncmp(options, "password", 8) == 0) {
+            if (vs->fips) {
+                fprintf(stderr,
+                        "VNC password auth disabled due to FIPS mode\n");
+                g_free(vs->display);
+                vs->display = NULL;
+                return -1;
+            }
             password = 1; /* Require password auth */
         } else if (strncmp(options, "reverse", 7) == 0) {
             reverse = 1;
ui/vnc.h +1 -0
index a851ebd..8746a98 100644
@@ -160,6 +160,7 @@ struct VncDisplay
     char *display;
     char *password;
     time_t expires;
+    int fips;
     int auth;
     bool lossy;
     bool non_adaptive;
#1 lore raw

Am 01.05.2012 23:20, schrieb Paul Moore:

Quoted 6 lines

FIPS 140-2 requires disabling certain ciphers, including DES, which is used by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when the host system is operating in FIPS mode.

This patch causes qemu to emits a syslog entry indicating that VNC password

"to emit"

Quoted 4 lines

auth is disabled when it detects the host is running in FIPS mode, and unless a VNC password was specified on the command line it continues normally. However, if a VNC password was given on the command line, qemu fails with an error message to stderr explaining that that VNC password

"explaining that VNC"

Quoted 3 lines

auth is not allowed in FIPS mode.

Interesting feature. :)

ui/vnc.c line 35

Quoted 9 lines
ui/vnc.c +1 -0
index deb9ecd..620791e 100644
@@ -32,6 +32,7 @@
 #include "acl.h"
 #include "qemu-objects.h"
 #include "qmp-commands.h"
+#include <syslog.h>

syslog.h is POSIX, but it'll need a guard for mingw32.

ui/vnc.c static DisplayChangeListener *dcl; · line 58

Quoted 11 lines
ui/vnc.c +7 -0
@@ -48,6 +49,24 @@ static DisplayChangeListener *dcl;
 static int vnc_cursor_define(VncState *vs);
 static void vnc_release_modifiers(VncState *vs);
 
+static int fips_enabled(void)
+{
+    int enabled = 0;
+    char value;
+    FILE *fds;
+
+    fds = fopen("/proc/sys/crypto/fips_enabled", "r");

How standardized is this? Should we limit this to __linux__ or something?

ui/vnc.c static DisplayChangeListener *dcl; · line 68

Quoted 10 lines
ui/vnc.c +10 -0
+    if (fds == NULL) {
+        return 0;
+    }
+    if (fread(&value, sizeof(value), 1, fds) == 1 && value == '1') {
+        enabled = 1;
+    }
+    fclose(fds);
+
+    return enabled;
+}

bool would seem nicer as return type and field type below.

Andreas

Quoted 17 lines
ui/vnc.c +1 -0
+
 static void vnc_set_share_mode(VncState *vs, VncShareMode mode)
 {
 #ifdef _VNC_DEBUG
ui/vnc.h +1 -0
index a851ebd..8746a98 100644
@@ -160,6 +160,7 @@ struct VncDisplay
     char *display;
     char *password;
     time_t expires;
+    int fips;
     int auth;
     bool lossy;
     bool non_adaptive;
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#2 lore raw
Quoted 3 lines · Andreas F??rber
Quoted 1 line

+ fds = fopen("/proc/sys/crypto/fips_enabled", "r");

How standardized is this? Should we limit this to __linux__ or something?

It's completelt non-standard and doesn't even exist in mainline Linux.

All the FIPS bullshit is a RHEL-private feature, which is where this patch should stay as well.

#3 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines · Andreas F??rber
Quoted 1 line

+ fds = fopen("/proc/sys/crypto/fips_enabled", "r");

How standardized is this? Should we limit this to __linux__ or something?

It's completelt non-standard and doesn't even exist in mainline Linux.

All the FIPS bullshit is a RHEL-private feature, which is where this patch should stay as well.

You really should check your facts before making such grand assertions that are trivially disprovable

It *is* in the mainline kernel:

  $ wget https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.3.4.tar.bz2
  $ tar jxvf linux-3.3.4.tar.bz2
  $ cd linux-3.3.4
  $ find | grep -i fips
  ./crypto/fips.c
  ./include/linux/fips.h
  $ find -type f | xargs grep fips_enabled
  ./drivers/char/random.c:		if (fips_enabled) {
  ./crypto/fips.c:int fips_enabled;
  ./crypto/fips.c:EXPORT_SYMBOL_GPL(fips_enabled);
  ./crypto/fips.c:	fips_enabled = !!simple_strtol(str, NULL, 0);
  ./crypto/fips.c:		fips_enabled ? "enabled" : "disabled");
  ./crypto/tcrypt.c:	if (fips_enabled && ret == -EINVAL)
  ./crypto/tcrypt.c:	if (!fips_enabled)
  ./crypto/testmgr.c:		if (fips_enabled && !alg_test_descs[i].fips_allowed)
  ./crypto/testmgr.c:	if (fips_enabled && ((i >= 0 && !alg_test_descs[i].fips_allowed) ||
  ./crypto/testmgr.c:	if (fips_enabled && rc)
  ./crypto/testmgr.c:	if (fips_enabled && !rc)
  ./crypto/proc.c:		.procname       = "fips_enabled",
  ./crypto/proc.c:		.data           = &fips_enabled,
  ./include/linux/fips.h:extern int fips_enabled;
  ./include/linux/fips.h:#define fips_enabled 0

It is *not* solely "RHEL bullshit":

  $ cat /etc/fedora-release
  Fedora release 17 (Beefy Miracle)
  $ rpm -qf /lib64/libfipscheck.so.1
  fipscheck-lib-1.3.0-3.fc17.x86_64

It *is* in all upstream crypto libraries:

 # wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.5.0.tar.bz2
 # tar jxvf libgcrypt-1.5.0.tar.bz2
 # cd libgcrypt-1.5.0
 # find | grep fips
 ./random/random-fips.c
 ./src/fips.c
 ./tests/fips186-dsa.c
 ./tests/fipsdrv.c
 ./doc/fips-fsm.pdf
 ./doc/fips-fsm.fig
 ./doc/fips-fsm.png
 ./doc/fips-fsm.eps
 # wget http://www.openssl.org/source/openssl-1.0.1b.tar.gz
 # tar zxvf openssl-1.0.1b.tar.gz
 # cd openssl-1.0.1b
 # find | grep fips
 ./test/testfipsssl
 ./crypto/dsa/fips186a.txt
 ./crypto/o_fips.c
 ./crypto/evp/evp_fips.c
 ./crypto/fips_err.h
 ./crypto/fips_ers.c
 # wget ftp://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/NSS_3_13_4_RTM/src/nss-3.13.4.tar.gz
 # tar zxvf nss-3.13.4.tar.gz
 # cd nss-3.13.4
 # find | grep fips
 ./mozilla/security/nss/lib/softoken/fipsaudt.c
 ./mozilla/security/nss/lib/softoken/fipstest.c
 ./mozilla/security/nss/lib/softoken/fipstokn.c
 ./mozilla/security/nss/tests/fips
 ./mozilla/security/nss/tests/fips/fips.sh
 ./mozilla/security/nss/cmd/fipstest
 ./mozilla/security/nss/cmd/fipstest/dsa.sh
 ./mozilla/security/nss/cmd/fipstest/rsa.sh
 ./mozilla/security/nss/cmd/fipstest/manifest.mn
 ./mozilla/security/nss/cmd/fipstest/rng.sh
 ./mozilla/security/nss/cmd/fipstest/fipstest.c
 ./mozilla/security/nss/cmd/fipstest/sha.sh
 ./mozilla/security/nss/cmd/fipstest/hmac.sh
 ./mozilla/security/nss/cmd/fipstest/tdea.sh
 ./mozilla/security/nss/cmd/fipstest/Makefile
 ./mozilla/security/nss/cmd/fipstest/ecdsa.sh
 ./mozilla/security/nss/cmd/fipstest/aes.sh

And fully documented by upstreams too

http://www.gnupg.org/documentation/manuals/gcrypt/Enabling-FIPS-mode.html
https://www.mozilla.org/projects/security/pki/nss/fips/
http://www.openssl.org/docs/fips/fipsnotes.html

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
author
#4 lore raw
In reply to Andreas Färber
Quoted 11 lines · Andreas Färber

Am 01.05.2012 23:20, schrieb Paul Moore:

Quoted 9 lines

FIPS 140-2 requires disabling certain ciphers, including DES, which is used
by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when the
host system is operating in FIPS mode.

This patch causes qemu to emits a syslog entry indicating that VNC password

Quoted 8 lines

"to emit"

Quoted 4 lines

auth is disabled when it detects the host is running in FIPS mode, and unless a VNC password was specified on the command line it continues normally. However, if a VNC password was given on the command line, qemu fails with an error message to stderr explaining that that VNC password

"explaining that VNC"

Thanks, typos fixed.

Quoted 5 lines
Quoted 3 lines

auth is not allowed in FIPS mode.

Interesting feature. :)

It would appear that depends on who you ask :)

Quoted 6 lines
Quoted 6 lines
ui/vnc.c +0 -0
index deb9ecd..620791e 100644
@@ -32,6 +32,7 @@
 
Quoted 7 lines

ui/vnc.c

Quoted 5 lines
ui/vnc.c +1 -0
 #include "acl.h"
 #include "qemu-objects.h"
 #include "qmp-commands.h"
 
+#include <syslog.h>

syslog.h is POSIX, but it'll need a guard for mingw32.

Is "#ifndef _WIN32" the right guard to use? Both here and where we make the actual syslog() call?

Quoted 5 lines
Quoted 5 lines
ui/vnc.c +0 -0
@@ -48,6 +49,24 @@ static DisplayChangeListener *dcl;
 
 static int vnc_cursor_define(VncState *vs);
 static void vnc_release_modifiers(VncState *vs);
 
Quoted 9 lines

ui/vnc.c static DisplayChangeListener *dcl; · line 58

Quoted 7 lines
ui/vnc.c +7 -0
+static int fips_enabled(void)
+{
+    int enabled = 0;
+    char value;
+    FILE *fds;
+
+    fds = fopen("/proc/sys/crypto/fips_enabled", "r");

How standardized is this? Should we limit this to __linux__ or something?

It is in the mainline Linux Kernel so fairly standard as far as Linux is concerned. However, it is Linux only to the best of my knowledge so I've gone ahead and protected it with __linux__ as you and others have mentioned.

Quoted 4 lines
Quoted 4 lines
ui/vnc.c +4 -0
+    if (fds == NULL) {
+        return 0;
+    }
+    if (fread(&value, sizeof(value), 1, fds) == 1 && value == '1') {
Quoted 8 lines

ui/vnc.c static DisplayChangeListener *dcl; · line 68

Quoted 6 lines
ui/vnc.c +6 -0
+        enabled = 1;
+    }
+    fclose(fds);
+
+    return enabled;
+}

bool would seem nicer as return type and field type below.

Yep, I agree.

I'll post a v2 later today; thanks for taking the time to review the patch and send your comments.

Signature · 2 lines
paul moore
security and virtualization @ redhat
#5 lore raw
In reply to Paul Moore
Quoted 4 lines · Paul Moore

FIPS 140-2 requires disabling certain ciphers, including DES, which is used by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when the host system is operating in FIPS mode.

Sorry, what?

Does FIPS really require software to detect when FIPS is enabled and actively disable features??? That's absurd.

Can you point to another software package that does something like this?

Regards,

Anthony Liguori

Quoted 113 lines

This patch causes qemu to emits a syslog entry indicating that VNC password auth is disabled when it detects the host is running in FIPS mode, and unless a VNC password was specified on the command line it continues normally. However, if a VNC password was given on the command line, qemu fails with an error message to stderr explaining that that VNC password auth is not allowed in FIPS mode.

---
  qemu-doc.texi |    8 +++++---
  ui/vnc.c      |   32 ++++++++++++++++++++++++++++++++
  ui/vnc.h      |    1 +
  3 files changed, 38 insertions(+), 3 deletions(-)
qemu-doc.texi +5 -3
index e5d7ac4..f9b113e 100644
@@ -1124,9 +1124,11 @@ the protocol limits passwords to 8 characters it should not be considered
  to provide high security. The password can be fairly easily brute-forced by
  a client making repeat connections. For this reason, a VNC server using password
  authentication should be restricted to only listen on the loopback interface
-or UNIX domain sockets. Password authentication is requested with the @code{password}
-option, and then once QEMU is running the password is set with the monitor. Until
-the monitor is used to set the password all clients will be rejected.
+or UNIX domain sockets. Password authentication is not supported when operating
+in FIPS 140-2 compliance mode as it requires the use of the DES cipher. Password
+authentication is requested with the @code{password} option, and then once QEMU
+is running the password is set with the monitor. Until the monitor is used to
+set the password all clients will be rejected.
 
  @example
  qemu [...OPTIONS...] -vnc :1,password -monitor stdio
ui/vnc.c +32 -0
index deb9ecd..620791e 100644
@@ -32,6 +32,7 @@
  #include "acl.h"
  #include "qemu-objects.h"
  #include "qmp-commands.h"
+#include<syslog.h>
 
  #define VNC_REFRESH_INTERVAL_BASE 30
  #define VNC_REFRESH_INTERVAL_INC  50
@@ -48,6 +49,24 @@ static DisplayChangeListener *dcl;
  static int vnc_cursor_define(VncState *vs);
  static void vnc_release_modifiers(VncState *vs);
 
+static int fips_enabled(void)
+{
+    int enabled = 0;
+    char value;
+    FILE *fds;
+
+    fds = fopen("/proc/sys/crypto/fips_enabled", "r");
+    if (fds == NULL) {
+        return 0;
+    }
+    if (fread(&value, sizeof(value), 1, fds) == 1&&  value == '1') {
+        enabled = 1;
+    }
+    fclose(fds);
+
+    return enabled;
+}
+
  static void vnc_set_share_mode(VncState *vs, VncShareMode mode)
  {
  #ifdef _VNC_DEBUG
@@ -2748,6 +2767,12 @@ void vnc_display_init(DisplayState *ds)
      dcl->idle = 1;
      vnc_display = vs;
 
+    vs->fips = fips_enabled();
+    VNC_DEBUG("FIPS mode %s\n", (vs->fips ? "enabled" : "disabled"));
+    if (vs->fips) {
+        syslog(LOG_NOTICE, "Disabling VNC password auth due to FIPS mode\n");
+    }
+
      vs->lsock = -1;
 
      vs->ds = ds;
@@ -2892,6 +2917,13 @@ int vnc_display_open(DisplayState *ds, const char *display)
      while ((options = strchr(options, ','))) {
          options++;
          if (strncmp(options, "password", 8) == 0) {
+            if (vs->fips) {
+                fprintf(stderr,
+                        "VNC password auth disabled due to FIPS mode\n");
+                g_free(vs->display);
+                vs->display = NULL;
+                return -1;
+            }
              password = 1; /* Require password auth */
          } else if (strncmp(options, "reverse", 7) == 0) {
              reverse = 1;
ui/vnc.h +1 -0
index a851ebd..8746a98 100644
@@ -160,6 +160,7 @@ struct VncDisplay
      char *display;
      char *password;
      time_t expires;
+    int fips;
      int auth;
      bool lossy;
      bool non_adaptive;
#6 lore raw

Anthony Liguori <[email protected]> wrote on 05/01/2012 06:26:05 PM:

Quoted 9 lines

Anthony Liguori <[email protected]>
05/01/2012 06:26 PM

To

Paul Moore <[email protected]>

cc

Quoted 9 lines

[email protected], George Wilson/Austin/IBM@IBMUS

Subject

Re: [Qemu-devel] [PATCH] vnc: disable VNC password authentication (security type 2) when in FIPS mode

Quoted 1 line · Paul Moore

FIPS 140-2 requires disabling certain ciphers, including DES, which is

used

Quoted 2 lines
Quoted 2 lines

by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when

the

Quoted 5 lines
Quoted 1 line

host system is operating in FIPS mode.

Sorry, what?

Does FIPS really require software to detect when FIPS is enabled

andactively

Quoted 3 lines

disable features??? That's absurd.

Can you point to another software package that does something like this?

Yes, it's true that only FIPS-approved algorithms are permitted for use in FIPS
mode. The kernel and all other FIPS 140-2 validated crypto modules like OpenSSL
and NSS are required to restrict algorithms to the approved set. The kernel
sets /proc/sys/crypto/fips_enabled so that programs can detect FIPS mode and
behave in accordance with the standard.

Quoted 7 lines

Regards,

Anthony Liguori

Quoted 2 lines

This patch causes qemu to emits a syslog entry indicating that VNC

password

Quoted 3 lines
Quoted 3 lines

auth is disabled when it detects the host is running in FIPS mode, and unless a VNC password was specified on the command line it continues normally. However, if a VNC password was given on the command line,

qemu

Quoted 85 lines

qemu-doc.texi the protocol limits passwords to 8

Quoted 15 lines

fails with an error message to stderr explaining that that VNC password auth is not allowed in FIPS mode.

---
  qemu-doc.texi |    8 +++++---
  ui/vnc.c      |   32 ++++++++++++++++++++++++++++++++
  ui/vnc.h      |    1 +
  3 files changed, 38 insertions(+), 3 deletions(-)
qemu-doc.texi +0 -0
index e5d7ac4..f9b113e 100644
@@ -1124,9 +1124,11 @@ the protocol limits passwords to 8

characters it should not be considered

qemu-doc.texi the protocol limits passwords to 8 · line 1124

Quoted 1 line
qemu-doc.texi +0 -0
  to provide high security. The password can be fairly easily

brute-forced by

qemu-doc.texi the protocol limits passwords to 8 · line 1125

Quoted 1 line
qemu-doc.texi +0 -0
  a client making repeat connections. For this reason, a VNC

server using password

qemu-doc.texi the protocol limits passwords to 8 · line 1126

Quoted 1 line
qemu-doc.texi +0 -0
  authentication should be restricted to only listen on the

loopback interface

qemu-doc.texi the protocol limits passwords to 8 · line 1127

Quoted 1 line
qemu-doc.texi +0 -1
-or UNIX domain sockets. Password authentication is requested with

the @code{password}

qemu-doc.texi the protocol limits passwords to 8 · line 1128

Quoted 1 line
qemu-doc.texi +0 -1
-option, and then once QEMU is running the password is set with

the monitor. Until

qemu-doc.texi the protocol limits passwords to 8 · line 1127

Quoted 2 lines
qemu-doc.texi +1 -1
-the monitor is used to set the password all clients will be rejected.
+or UNIX domain sockets. Password authentication is not supported

when operating

qemu-doc.texi the protocol limits passwords to 8 · line 1128

Quoted 1 line
qemu-doc.texi +1 -0
+in FIPS 140-2 compliance mode as it requires the use of the DES

cipher. Password

qemu-doc.texi the protocol limits passwords to 8 · line 1129

Quoted 1 line
qemu-doc.texi +1 -0
+authentication is requested with the @code{password} option, and

then once QEMU

qemu-doc.texi the protocol limits passwords to 8 · line 1130

Quoted 1 line
qemu-doc.texi +1 -0
+is running the password is set with the monitor. Until the

monitor is used to

Quoted 42 lines
qemu-doc.texi +1 -0
+set the password all clients will be rejected.
 
  @example
  qemu [...OPTIONS...] -vnc :1,password -monitor stdio
ui/vnc.c +19 -0
index deb9ecd..620791e 100644
@@ -32,6 +32,7 @@
  #include "acl.h"
  #include "qemu-objects.h"
  #include "qmp-commands.h"
+#include<syslog.h>
 
  #define VNC_REFRESH_INTERVAL_BASE 30
  #define VNC_REFRESH_INTERVAL_INC  50
@@ -48,6 +49,24 @@ static DisplayChangeListener *dcl;
  static int vnc_cursor_define(VncState *vs);
  static void vnc_release_modifiers(VncState *vs);
 
+static int fips_enabled(void)
+{
+    int enabled = 0;
+    char value;
+    FILE *fds;
+
+    fds = fopen("/proc/sys/crypto/fips_enabled", "r");
+    if (fds == NULL) {
+        return 0;
+    }
+    if (fread(&value, sizeof(value), 1, fds) == 1&&  value == '1') {
+        enabled = 1;
+    }
+    fclose(fds);
+
+    return enabled;
+}
+
  static void vnc_set_share_mode(VncState *vs, VncShareMode mode)
  {
  #ifdef _VNC_DEBUG

ui/vnc.c void vnc_display_init(DisplayState *ds) · line 2773

Quoted 7 lines
ui/vnc.c +4 -0
@@ -2748,6 +2767,12 @@ void vnc_display_init(DisplayState *ds)
      dcl->idle = 1;
      vnc_display = vs;
 
+    vs->fips = fips_enabled();
+    VNC_DEBUG("FIPS mode %s\n", (vs->fips ? "enabled" : "disabled"));
+    if (vs->fips) {
+        syslog(LOG_NOTICE, "Disabling VNC password auth due to

FIPS mode\n");

Quoted 13 lines

ui/vnc.c int vnc_display_open(DisplayState *ds,

Quoted 6 lines
ui/vnc.c +2 -0
+    }
+
      vs->lsock = -1;
 
      vs->ds = ds;
@@ -2892,6 +2917,13 @@ int vnc_display_open(DisplayState *ds,

const char *display)

Quoted 6 lines
ui/vnc.c +3 -0
      while ((options = strchr(options, ','))) {
          options++;
          if (strncmp(options, "password", 8) == 0) {
+            if (vs->fips) {
+                fprintf(stderr,
+                        "VNC password auth disabled due to FIPS mode

\n");

Quoted 14 lines
Quoted 14 lines
ui/vnc.c +4 -0
+                g_free(vs->display);
+                vs->display = NULL;
+                return -1;
+            }
              password = 1; /* Require password auth */
          } else if (strncmp(options, "reverse", 7) == 0) {
              reverse = 1;
ui/vnc.h +0 -0
index a851ebd..8746a98 100644
@@ -160,6 +160,7 @@ struct VncDisplay
      char *display;
      char *password;
Quoted 9 lines

ui/vnc.h struct VncDisplay · line 166

Quoted 8 lines
ui/vnc.h +1 -0
      time_t expires;
+    int fips;
      int auth;
      bool lossy;
      bool non_adaptive;

Regards,
George Wilson

#7 lore raw
Quoted 35 lines · George Wilson

Anthony Liguori<[email protected]> wrote on 05/01/2012 06:26:05 PM:

Quoted 9 lines

Anthony Liguori<[email protected]>
05/01/2012 06:26 PM

To

Paul Moore<[email protected]>

cc

Quoted 9 lines

[email protected], George Wilson/Austin/IBM@IBMUS

Subject

Re: [Qemu-devel] [PATCH] vnc: disable VNC password authentication (security type 2) when in FIPS mode

Quoted 1 line · Paul Moore

FIPS 140-2 requires disabling certain ciphers, including DES, which is

used

Quoted 2 lines
Quoted 2 lines

by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when

the

Quoted 5 lines
Quoted 1 line

host system is operating in FIPS mode.

Sorry, what?

Does FIPS really require software to detect when FIPS is enabled

andactively

Quoted 3 lines

disable features??? That's absurd.

Can you point to another software package that does something like this?

Quoted 9 lines

Yes, it's true that only FIPS-approved algorithms are permitted for use in FIPS
mode. The kernel and all other FIPS 140-2 validated crypto modules like OpenSSL
and NSS are required to restrict algorithms to the approved set. The kernel
sets /proc/sys/crypto/fips_enabled so that programs can detect FIPS mode and
behave in accordance with the standard.

But this is nonsensical. It would allow no-password to be configured for the VNC server but not DES? Why is that okay? It's not like we enable DES passwords by default. A user has to explicitly configure it.

Is there an open source app that actually keys off of fips_enabled?

Regards,

Anthony Liguori

Quoted 138 lines
Quoted 8 lines

Regards,

Anthony Liguori

Quoted 2 lines

This patch causes qemu to emits a syslog entry indicating that VNC

password

Quoted 3 lines
Quoted 3 lines

auth is disabled when it detects the host is running in FIPS mode, and unless a VNC password was specified on the command line it continues normally. However, if a VNC password was given on the command line,

qemu

Quoted 85 lines

qemu-doc.texi the protocol limits passwords to 8

Quoted 15 lines

fails with an error message to stderr explaining that that VNC password auth is not allowed in FIPS mode.

---
   qemu-doc.texi |    8 +++++---
   ui/vnc.c      |   32 ++++++++++++++++++++++++++++++++
   ui/vnc.h      |    1 +
   3 files changed, 38 insertions(+), 3 deletions(-)
qemu-doc.texi +0 -0
index e5d7ac4..f9b113e 100644
@@ -1124,9 +1124,11 @@ the protocol limits passwords to 8

characters it should not be considered

qemu-doc.texi the protocol limits passwords to 8 · line 1124

Quoted 1 line
qemu-doc.texi +0 -0
   to provide high security. The password can be fairly easily

brute-forced by

qemu-doc.texi the protocol limits passwords to 8 · line 1125

Quoted 1 line
qemu-doc.texi +0 -0
   a client making repeat connections. For this reason, a VNC

server using password

qemu-doc.texi the protocol limits passwords to 8 · line 1126

Quoted 1 line
qemu-doc.texi +0 -0
   authentication should be restricted to only listen on the

loopback interface

qemu-doc.texi the protocol limits passwords to 8 · line 1127

Quoted 1 line
qemu-doc.texi +0 -1
-or UNIX domain sockets. Password authentication is requested with

the @code{password}

qemu-doc.texi the protocol limits passwords to 8 · line 1128

Quoted 1 line
qemu-doc.texi +0 -1
-option, and then once QEMU is running the password is set with

the monitor. Until

qemu-doc.texi the protocol limits passwords to 8 · line 1127

Quoted 2 lines
qemu-doc.texi +1 -1
-the monitor is used to set the password all clients will be rejected.
+or UNIX domain sockets. Password authentication is not supported

when operating

qemu-doc.texi the protocol limits passwords to 8 · line 1128

Quoted 1 line
qemu-doc.texi +1 -0
+in FIPS 140-2 compliance mode as it requires the use of the DES

cipher. Password

qemu-doc.texi the protocol limits passwords to 8 · line 1129

Quoted 1 line
qemu-doc.texi +1 -0
+authentication is requested with the @code{password} option, and

then once QEMU

qemu-doc.texi the protocol limits passwords to 8 · line 1130

Quoted 1 line
qemu-doc.texi +1 -0
+is running the password is set with the monitor. Until the

monitor is used to

Quoted 42 lines
qemu-doc.texi +1 -0
+set the password all clients will be rejected.
 
   @example
   qemu [...OPTIONS...] -vnc :1,password -monitor stdio
ui/vnc.c +19 -0
index deb9ecd..620791e 100644
@@ -32,6 +32,7 @@
   #include "acl.h"
   #include "qemu-objects.h"
   #include "qmp-commands.h"
+#include<syslog.h>
 
   #define VNC_REFRESH_INTERVAL_BASE 30
   #define VNC_REFRESH_INTERVAL_INC  50
@@ -48,6 +49,24 @@ static DisplayChangeListener *dcl;
   static int vnc_cursor_define(VncState *vs);
   static void vnc_release_modifiers(VncState *vs);
 
+static int fips_enabled(void)
+{
+    int enabled = 0;
+    char value;
+    FILE *fds;
+
+    fds = fopen("/proc/sys/crypto/fips_enabled", "r");
+    if (fds == NULL) {
+        return 0;
+    }
+    if (fread(&value, sizeof(value), 1, fds) == 1&&   value == '1') {
+        enabled = 1;
+    }
+    fclose(fds);
+
+    return enabled;
+}
+
   static void vnc_set_share_mode(VncState *vs, VncShareMode mode)
   {
   #ifdef _VNC_DEBUG

ui/vnc.c void vnc_display_init(DisplayState *ds) · line 2773

Quoted 7 lines
ui/vnc.c +4 -0
@@ -2748,6 +2767,12 @@ void vnc_display_init(DisplayState *ds)
       dcl->idle = 1;
       vnc_display = vs;
 
+    vs->fips = fips_enabled();
+    VNC_DEBUG("FIPS mode %s\n", (vs->fips ? "enabled" : "disabled"));
+    if (vs->fips) {
+        syslog(LOG_NOTICE, "Disabling VNC password auth due to

FIPS mode\n");

Quoted 13 lines

ui/vnc.c int vnc_display_open(DisplayState *ds,

Quoted 6 lines
ui/vnc.c +2 -0
+    }
+
       vs->lsock = -1;
 
       vs->ds = ds;
@@ -2892,6 +2917,13 @@ int vnc_display_open(DisplayState *ds,

const char *display)

Quoted 6 lines
ui/vnc.c +3 -0
       while ((options = strchr(options, ','))) {
           options++;
           if (strncmp(options, "password", 8) == 0) {
+            if (vs->fips) {
+                fprintf(stderr,
+                        "VNC password auth disabled due to FIPS mode

\n");

Quoted 14 lines
Quoted 14 lines
ui/vnc.c +4 -0
+                g_free(vs->display);
+                vs->display = NULL;
+                return -1;
+            }
               password = 1; /* Require password auth */
           } else if (strncmp(options, "reverse", 7) == 0) {
               reverse = 1;
ui/vnc.h +0 -0
index a851ebd..8746a98 100644
@@ -160,6 +160,7 @@ struct VncDisplay
       char *display;
       char *password;
Quoted 9 lines

ui/vnc.h struct VncDisplay · line 166

Quoted 8 lines
ui/vnc.h +1 -0
       time_t expires;
+    int fips;
       int auth;
       bool lossy;
       bool non_adaptive;

Regards,
George Wilson

#8 lore raw

Anthony Liguori <[email protected]> wrote on 05/01/2012 06:45:47 PM:

Quoted 9 lines

Anthony Liguori <[email protected]>
05/01/2012 06:45 PM

To

George Wilson/Austin/IBM@IBMUS

cc

Quoted 10 lines

Paul Moore <[email protected]>, [email protected]

Subject

Re: [Qemu-devel] [PATCH] vnc: disable VNC password authentication (security type 2) when in FIPS mode

Quoted 2 lines · George Wilson

Anthony Liguori<[email protected]> wrote on 05/01/2012 06:26:05

PM:

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

Anthony Liguori<[email protected]>
05/01/2012 06:26 PM

To

Paul Moore<[email protected]>

cc

[email protected], George Wilson/Austin/IBM@IBMUS

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Subject

Re: [Qemu-devel] [PATCH] vnc: disable VNC password authentication (security type 2) when in FIPS mode

Quoted 1 line · Paul Moore

FIPS 140-2 requires disabling certain ciphers, including DES, which

is

Quoted 3 lines
Quoted 3 lines

used

Quoted 2 lines
Quoted 2 lines

by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth

when

Quoted 10 lines
Quoted 10 lines

the

Quoted 5 lines
Quoted 1 line

host system is operating in FIPS mode.

Sorry, what?

Does FIPS really require software to detect when FIPS is enabled

andactively

Quoted 3 lines

disable features??? That's absurd.

Can you point to another software package that does something like

this?

Quoted 2 lines
Quoted 2 lines

Yes, it's true that only FIPS-approved algorithms are permitted for use

in

Quoted 2 lines
Quoted 2 lines

FIPS
mode. The kernel and all other FIPS 140-2 validated crypto modules

like

Quoted 4 lines
Quoted 4 lines

OpenSSL
and NSS are required to restrict algorithms to the approved set. The kernel
sets /proc/sys/crypto/fips_enabled so that programs can detect FIPS

mode

Quoted 8 lines
Quoted 2 lines

and
behave in accordance with the standard.

But this is nonsensical. It would allow no-password to be configured for the VNC
server but not DES? Why is that okay? It's not like we enable DES passwords by
default. A user has to explicitly configure it.

Because the standard says so :-) If you're going to encrypt and need to be FIPS 140-2 compliant, choose a FIPS-approved algorithm like AES. And adhere to approved key sizes and modes. And make sure the algorithm does self tests. And so on. It's best call into a FIPS-compliant library. If the passwords are sent over an untrusted network, it's not OK not to encrypt them from a security POV.

Quoted 2 lines

Is there an open source app that actually keys off of fips_enabled?

libgcrypt is one example:

$strings /lib64/libgcrypt.so.11.5.3 | grep fips_enabled /etc/gcrypt/fips_enabled /proc/sys/crypto/fips_enabled

info libgcrypt has some details on FIPS mode.

Quoted 15 lines

Regards,

Anthony Liguori

Quoted 10 lines
Quoted 8 lines

Regards,

Anthony Liguori

Quoted 2 lines

This patch causes qemu to emits a syslog entry indicating that VNC

password

Quoted 1 line
Quoted 1 line

auth is disabled when it detects the host is running in FIPS mode,

and

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

unless a VNC password was specified on the command line it continues normally. However, if a VNC password was given on the command line,

qemu

Quoted 1 line
Quoted 1 line

fails with an error message to stderr explaining that that VNC

password

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines

qemu-doc.texi the protocol limits passwords to 8

Quoted 14 lines

auth is not allowed in FIPS mode.

---
   qemu-doc.texi |    8 +++++---
   ui/vnc.c      |   32 ++++++++++++++++++++++++++++++++
   ui/vnc.h      |    1 +
   3 files changed, 38 insertions(+), 3 deletions(-)
qemu-doc.texi +0 -0
index e5d7ac4..f9b113e 100644
@@ -1124,9 +1124,11 @@ the protocol limits passwords to 8

characters it should not be considered

qemu-doc.texi the protocol limits passwords to 8 · line 1124

Quoted 1 line
qemu-doc.texi +0 -0
   to provide high security. The password can be fairly easily

brute-forced by

Quoted 1 line
qemu-doc.texi +0 -0
   a client making repeat connections. For this reason, a VNC
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

server using password

qemu-doc.texi the protocol limits passwords to 8 · line 1126

Quoted 1 line
qemu-doc.texi +0 -0
   authentication should be restricted to only listen on the

loopback interface

qemu-doc.texi the protocol limits passwords to 8 · line 1127

Quoted 1 line
qemu-doc.texi +0 -1
-or UNIX domain sockets. Password authentication is requested with

the @code{password}

qemu-doc.texi the protocol limits passwords to 8 · line 1128

Quoted 1 line
qemu-doc.texi +0 -1
-option, and then once QEMU is running the password is set with

the monitor. Until

Quoted 1 line
qemu-doc.texi +0 -1
-the monitor is used to set the password all clients will be

rejected.

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines

qemu-doc.texi the protocol limits passwords to 8 · line 1127

Quoted 1 line
qemu-doc.texi +1 -0
+or UNIX domain sockets. Password authentication is not supported

when operating

qemu-doc.texi the protocol limits passwords to 8 · line 1128

Quoted 1 line
qemu-doc.texi +1 -0
+in FIPS 140-2 compliance mode as it requires the use of the DES

cipher. Password

qemu-doc.texi the protocol limits passwords to 8 · line 1129

Quoted 1 line
qemu-doc.texi +1 -0
+authentication is requested with the @code{password} option, and

then once QEMU

qemu-doc.texi the protocol limits passwords to 8 · line 1130

Quoted 1 line
qemu-doc.texi +1 -0
+is running the password is set with the monitor. Until the

monitor is used to

Quoted 20 lines
qemu-doc.texi +1 -0
+set the password all clients will be rejected.
 
   @example
   qemu [...OPTIONS...] -vnc :1,password -monitor stdio
ui/vnc.c +1 -0
index deb9ecd..620791e 100644
@@ -32,6 +32,7 @@
   #include "acl.h"
   #include "qemu-objects.h"
   #include "qmp-commands.h"
+#include<syslog.h>
 
   #define VNC_REFRESH_INTERVAL_BASE 30
   #define VNC_REFRESH_INTERVAL_INC  50
@@ -48,6 +49,24 @@ static DisplayChangeListener *dcl;
   static int vnc_cursor_define(VncState *vs);
   static void vnc_release_modifiers(VncState *vs);
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

ui/vnc.c static DisplayChangeListener *dcl;

Quoted 11 lines
ui/vnc.c +11 -0
+static int fips_enabled(void)
+{
+    int enabled = 0;
+    char value;
+    FILE *fds;
+
+    fds = fopen("/proc/sys/crypto/fips_enabled", "r");
+    if (fds == NULL) {
+        return 0;
+    }
+    if (fread(&value, sizeof(value), 1, fds) == 1&&   value == '1')

{

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
ui/vnc.c +7 -0
+        enabled = 1;
+    }
+    fclose(fds);
+
+    return enabled;
+}
+
   static void vnc_set_share_mode(VncState *vs, VncShareMode mode)
   {
   #ifdef _VNC_DEBUG
@@ -2748,6 +2767,12 @@ void vnc_display_init(DisplayState *ds)
       dcl->idle = 1;
       vnc_display = vs;
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

ui/vnc.c void vnc_display_init(DisplayState *ds) · line 2771

Quoted 2 lines
ui/vnc.c +2 -0
+    vs->fips = fips_enabled();
+    VNC_DEBUG("FIPS mode %s\n", (vs->fips ? "enabled" :

"disabled"));

Quoted 41 lines
Quoted 41 lines
Quoted 16 lines

ui/vnc.c void vnc_display_init(DisplayState *ds) · line 2773

Quoted 2 lines
ui/vnc.c +2 -0
+    if (vs->fips) {
+        syslog(LOG_NOTICE, "Disabling VNC password auth due to

FIPS mode\n");

ui/vnc.c int vnc_display_open(DisplayState *ds,

Quoted 6 lines
ui/vnc.c +2 -0
+    }
+
       vs->lsock = -1;
 
       vs->ds = ds;
@@ -2892,6 +2917,13 @@ int vnc_display_open(DisplayState *ds,

const char *display)

Quoted 6 lines
ui/vnc.c +3 -0
       while ((options = strchr(options, ','))) {
           options++;
           if (strncmp(options, "password", 8) == 0) {
+            if (vs->fips) {
+                fprintf(stderr,
+                        "VNC password auth disabled due to FIPS mode

\n");

Quoted 23 lines
Quoted 22 lines
ui/vnc.c +4 -0
+                g_free(vs->display);
+                vs->display = NULL;
+                return -1;
+            }
               password = 1; /* Require password auth */
           } else if (strncmp(options, "reverse", 7) == 0) {
               reverse = 1;
ui/vnc.h +1 -0
index a851ebd..8746a98 100644
@@ -160,6 +160,7 @@ struct VncDisplay
       char *display;
       char *password;
       time_t expires;
+    int fips;
       int auth;
       bool lossy;
       bool non_adaptive;
Quoted 3 lines
Quoted 2 lines

Regards,
George Wilson

Regards,
George Wilson

#9 lore raw
In reply to Anthony Liguori
Quoted 46 lines · Anthony Liguori
Quoted 35 lines · George Wilson

Anthony Liguori<[email protected]> wrote on 05/01/2012 06:26:05 PM:

Quoted 9 lines

Anthony Liguori<[email protected]>
05/01/2012 06:26 PM

To

Paul Moore<[email protected]>

cc

Quoted 9 lines

[email protected], George Wilson/Austin/IBM@IBMUS

Subject

Re: [Qemu-devel] [PATCH] vnc: disable VNC password authentication (security type 2) when in FIPS mode

Quoted 1 line · Paul Moore

FIPS 140-2 requires disabling certain ciphers, including DES, which is

used

Quoted 2 lines
Quoted 2 lines

by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when

the

Quoted 5 lines
Quoted 1 line

host system is operating in FIPS mode.

Sorry, what?

Does FIPS really require software to detect when FIPS is enabled

andactively

Quoted 3 lines

disable features??? That's absurd.

Can you point to another software package that does something like this?

Quoted 9 lines

Yes, it's true that only FIPS-approved algorithms are permitted for use in FIPS
mode. The kernel and all other FIPS 140-2 validated crypto modules like OpenSSL
and NSS are required to restrict algorithms to the approved set. The kernel
sets /proc/sys/crypto/fips_enabled so that programs can detect FIPS mode and
behave in accordance with the standard.

Quoted 4 lines

But this is nonsensical. It would allow no-password to be configured for the VNC server but not DES? Why is that okay? It's not like we enable DES passwords by default. A user has to explicitly configure it.

In the wonderful world of security certifications, "sensible" is rarely a relevant factor. To answer your point though, FIPS itself is just about restricting use of insecure algorithms. Whether an application uses authentication or not, is outside the scope of that. Other security standards are responsible for dictating whether authentication is mandatory or not.

Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#10 lore raw
In reply to Anthony Liguori
Quoted 6 lines · Anthony Liguori
Quoted 4 lines · Paul Moore

FIPS 140-2 requires disabling certain ciphers, including DES, which is used by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when the host system is operating in FIPS mode.

Quoted 6 lines

Sorry, what?

Does FIPS really require software to detect when FIPS is enabled and actively disable features??? That's absurd.

Can you point to another software package that does something like this?

All the SSL libraries for a start (NSS, OpenSSL & GNUTLS). If we were using one of those for the VNC DES code we would be disabled.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#11 lore raw
In reply to Paul Moore
Quoted 51 lines · Paul Moore

FIPS 140-2 requires disabling certain ciphers, including DES, which is used by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when the host system is operating in FIPS mode.

This patch causes qemu to emits a syslog entry indicating that VNC password auth is disabled when it detects the host is running in FIPS mode, and unless a VNC password was specified on the command line it continues normally. However, if a VNC password was given on the command line, qemu fails with an error message to stderr explaining that that VNC password auth is not allowed in FIPS mode.

---
 qemu-doc.texi |    8 +++++---
 ui/vnc.c      |   32 ++++++++++++++++++++++++++++++++
 ui/vnc.h      |    1 +
 3 files changed, 38 insertions(+), 3 deletions(-)
qemu-doc.texi +5 -3
index e5d7ac4..f9b113e 100644
@@ -1124,9 +1124,11 @@ the protocol limits passwords to 8 characters it should not be considered
 to provide high security. The password can be fairly easily brute-forced by
 a client making repeat connections. For this reason, a VNC server using password
 authentication should be restricted to only listen on the loopback interface
-or UNIX domain sockets. Password authentication is requested with the @code{password}
-option, and then once QEMU is running the password is set with the monitor. Until
-the monitor is used to set the password all clients will be rejected.
+or UNIX domain sockets. Password authentication is not supported when operating
+in FIPS 140-2 compliance mode as it requires the use of the DES cipher. Password
+authentication is requested with the @code{password} option, and then once QEMU
+is running the password is set with the monitor. Until the monitor is used to
+set the password all clients will be rejected.
 
 @example
 qemu [...OPTIONS...] -vnc :1,password -monitor stdio
ui/vnc.c +1 -0
index deb9ecd..620791e 100644
@@ -32,6 +32,7 @@
 #include "acl.h"
 #include "qemu-objects.h"
 #include "qmp-commands.h"
+#include <syslog.h>
 
 #define VNC_REFRESH_INTERVAL_BASE 30
 #define VNC_REFRESH_INTERVAL_INC  50

ui/vnc.c static DisplayChangeListener *dcl; · line 52

Quoted 4 lines
ui/vnc.c +1 -0
@@ -48,6 +49,24 @@ static DisplayChangeListener *dcl;
 static int vnc_cursor_define(VncState *vs);
 static void vnc_release_modifiers(VncState *vs);
 
+static int fips_enabled(void)

s/int/bool/ and use true/false as values

Quoted 6 lines
ui/vnc.c +6 -0
+{
+    int enabled = 0;
+    char value;
+    FILE *fds;
+
+    fds = fopen("/proc/sys/crypto/fips_enabled", "r");

ui/vnc.c static DisplayChangeListener *dcl; · line 68

Quoted 10 lines
ui/vnc.c +10 -0
+    if (fds == NULL) {
+        return 0;
+    }
+    if (fread(&value, sizeof(value), 1, fds) == 1 && value == '1') {
+        enabled = 1;
+    }
+    fclose(fds);
+
+    return enabled;
+}

As already pointed out,wWe should probably make this depend on __linux__, and 'return false' fo other platforms.

ui/vnc.c void vnc_display_init(DisplayState *ds) · line 2774

Quoted 13 lines
ui/vnc.c +6 -0
+
 static void vnc_set_share_mode(VncState *vs, VncShareMode mode)
 {
 #ifdef _VNC_DEBUG
@@ -2748,6 +2767,12 @@ void vnc_display_init(DisplayState *ds)
     dcl->idle = 1;
     vnc_display = vs;
 
+    vs->fips = fips_enabled();
+    VNC_DEBUG("FIPS mode %s\n", (vs->fips ? "enabled" : "disabled"));
+    if (vs->fips) {
+        syslog(LOG_NOTICE, "Disabling VNC password auth due to FIPS mode\n");
+    }

I think this syslog message is better placed in the next chunk of the patch where you actually test the vs->fips value.

Quoted 8 lines
ui/vnc.c +1 -0
+
     vs->lsock = -1;
 
     vs->ds = ds;
@@ -2892,6 +2917,13 @@ int vnc_display_open(DisplayState *ds, const char *display)
     while ((options = strchr(options, ','))) {
         options++;
         if (strncmp(options, "password", 8) == 0) {

ui/vnc.c int vnc_display_open(DisplayState *ds, const char *display) · line 2929

Quoted 10 lines
ui/vnc.c +7 -0
+            if (vs->fips) {
+                fprintf(stderr,
+                        "VNC password auth disabled due to FIPS mode\n");
+                g_free(vs->display);
+                vs->display = NULL;
+                return -1;
+            }
             password = 1; /* Require password auth */
         } else if (strncmp(options, "reverse", 7) == 0) {
             reverse = 1;

Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
author
#12 lore raw
Quoted 16 lines · Daniel P. Berrange
Quoted 15 lines · Paul Moore
ui/vnc.c +1 -0
index deb9ecd..620791e 100644
@@ -32,6 +32,7 @@
 
 #include "acl.h"
 #include "qemu-objects.h"
 #include "qmp-commands.h"
 
+#include <syslog.h>
 

#define VNC_REFRESH_INTERVAL_BASE 30
#define VNC_REFRESH_INTERVAL_INC 50

Quoted 8 lines

ui/vnc.c static DisplayChangeListener *dcl; · line 53

Quoted 6 lines
ui/vnc.c +1 -0
@@ -48,6 +49,24 @@ static DisplayChangeListener *dcl;
 
 static int vnc_cursor_define(VncState *vs);
 static void vnc_release_modifiers(VncState *vs);
 
+static int fips_enabled(void)

s/int/bool/ and use true/false as values

Fixed.

Quoted 11 lines
Quoted 11 lines
ui/vnc.c +11 -0
+{
+    int enabled = 0;
+    char value;
+    FILE *fds;
+
+    fds = fopen("/proc/sys/crypto/fips_enabled", "r");
+    if (fds == NULL) {
+        return 0;
+    }
+    if (fread(&value, sizeof(value), 1, fds) == 1 && value == '1') {
+        enabled = 1;
Quoted 8 lines

ui/vnc.c static DisplayChangeListener *dcl; · line 68

Quoted 5 lines
ui/vnc.c +5 -0
+    }
+    fclose(fds);
+
+    return enabled;
+}

As already pointed out,wWe should probably make this depend on __linux__, and 'return false' fo other platforms.

Yep, that makes sense. Fixed.

Quoted 9 lines
Quoted 9 lines
ui/vnc.c +0 -0
 static void vnc_set_share_mode(VncState *vs, VncShareMode mode)
 {
 #ifdef _VNC_DEBUG
@@ -2748,6 +2767,12 @@ void vnc_display_init(DisplayState *ds)
 
     dcl->idle = 1;
     vnc_display = vs;
 
Quoted 8 lines

ui/vnc.c void vnc_display_init(DisplayState *ds)

Quoted 5 lines
ui/vnc.c +4 -0
+    vs->fips = fips_enabled();
+    VNC_DEBUG("FIPS mode %s\n", (vs->fips ? "enabled" : "disabled"));
+    if (vs->fips) {
+        syslog(LOG_NOTICE, "Disabling VNC password auth due to FIPS
 mode\n"); +    }

I think this syslog message is better placed in the next chunk of the patch where you actually test the vs->fips value.

My reasoning for placing it here is so that there would be some positive indication that VNC password auth is disabled even if the user isn't attempting to use the it. Although I can understand the reasoning for moving it down as well so that things are quieter in the non-passwd-auth case.

With this in mind, do you still think it should be moved down?

Regardless, thanks again for your time and comments.

Signature · 2 lines
paul moore
security and virtualization @ redhat