
diff -upr a/configure.ac d/configure.ac
--- a/configure.ac	Tue Nov 11 13:06:16 2025
+++ d/configure.ac	Fri Dec  5 10:11:55 2025
@@ -44,6 +44,11 @@ AC_ARG_ENABLE([insure],
   [enable_insure=$enableval],
   [enable_insure=no])
 
+AC_ARG_ENABLE([unveil],
+  [AS_HELP_STRING([--enable-unveil], [Build with support for unveil])],
+  [enable_unveil=$enableval],
+  [enable_unveil=no])
+
 AC_ARG_ENABLE([ipv6],
   [AS_HELP_STRING([--enable-ipv6], [Build with support for IPv6 (default: auto)])],
   [enable_ipv6=$enableval],
@@ -748,6 +753,9 @@ if test "x$enable_insure" = "xyes" ; then
   CC="insure -Zoi \"compiler $CC\""
   LIBS="$LIBS -lstdc++-2-libc6.1-1-2.9.0"
 fi
+if test "x$enable_unveil" = "xyes" ; then
+  AC_DEFINE([ENABLE_UNVEIL], [1], [Enable unveil])
+fi
 if test "x$enable_threaded_dns" = "xyes" ; then
   CFLAGS="$CFLAGS -DD_DNS_THREADED"
 fi
@@ -889,4 +897,5 @@ _AS_ECHO([  SVG enabled    : ${enable_svg}])
 _AS_ECHO([  WEBP enabled   : ${webp_ok}])
 _AS_ECHO([  Brotli enabled : ${brotli_ok}])
 _AS_ECHO([  IPv6 enabled   : ${enable_ipv6}])
+_AS_ECHO([  unveil enabled : ${enable_unveil}])
 _AS_ECHO([])
diff -upr a/dlib/dlib.c d/dlib/dlib.c
--- a/dlib/dlib.c	Tue Nov 11 13:06:16 2025
+++ d/dlib/dlib.c	Fri Dec  5 10:10:33 2025
@@ -950,6 +950,99 @@ char *dGethomedir (void)
 }
 
 /**
+ * Return the save directory in a static string
+ */
+char *dGetsavedir (void)
+{
+   static char *dillorc = NULL;
+   dillorc = dStrconcat(dGethomedir(), "/", ".dillo/dillorc", NULL);
+   FILE *In;
+   int len;
+   char *rcline = NULL, *value = NULL, *p;
+   if ((In = fopen(dillorc, "r")) == NULL) {
+      DLIB_MSG("dGetsavedir: unable to open dillorc.\n");
+      return (NULL);
+   }
+   while ((rcline = dGetline(In)) != NULL) {
+      if (strncmp(rcline, "save_dir", 8) == 0)
+         break;
+      dFree(rcline);
+   }
+   fclose(In);
+   if (!rcline) {
+      value = NULL;
+      DLIB_MSG("dGetsavedir: no 'save_dir' in dillorc..\n");
+   } else {
+      len = (int) strlen(rcline);
+      if (len && rcline[len - 1] == '\n')
+         rcline[len - 1] = 0;
+      if ((p = strchr(rcline, '='))) {
+         while (*++p == ' ');
+         value = dStrdup(p);
+      } else {
+         value = NULL;
+	 DLIB_MSG("dGetsavedir: error parsing value in dillorc.\n");
+      }
+   }
+   dFree(rcline);
+   return (value);
+}
+
+/**
+ * Return the enable_unveil value in a static string
+ */
+char *dGetenableunveil (void)
+{
+   static char *dillorc = NULL;
+   dillorc = dStrconcat(dGethomedir(), "/", ".dillo/dillorc", NULL);
+   FILE *In;
+   int len;
+   char *rcline = NULL, *value = NULL, *p;
+   if ((In = fopen(dillorc, "r")) == NULL) {
+      DLIB_MSG("dGetenableunveil: unable to open dillorc.\n");
+      return (NULL);
+   }
+   while ((rcline = dGetline(In)) != NULL) {
+      if (strncmp(rcline, "enable_unveil", 13) == 0)
+         break;
+      dFree(rcline);
+   }
+   fclose(In);
+   if (!rcline) {
+      value = NULL;
+      DLIB_MSG("dGetenableunveil: no 'enable_unveil' in dillorc.\n");
+   } else {
+      len = (int) strlen(rcline);
+      if (len && rcline[len - 1] == '\n')
+         rcline[len - 1] = 0;
+      if ((p = strchr(rcline, '='))) {
+         while (*++p == ' ');
+         value = dStrdup(p);
+      } else {
+         value = NULL;
+	 DLIB_MSG("dGetenableunveil: error parsing value in dillorc.\n");
+      }
+   }
+   dFree(rcline);
+   return (value);
+}
+
+/**
+ * Use unveil on OpenBSD
+ */
+void *dUnveil(const char *path, const char *perm)
+{
+    #ifdef ENABLE_UNVEIL
+    #ifdef __OpenBSD__
+    if (unveil(path, perm) == -1) {
+       DLIB_MSG("unveil(%s, %s) failed: %s\n", path, perm, strerror(errno));
+       exit(1);
+    }
+    #endif
+    #endif
+}
+
+/**
  * Get a line from a FILE stream.
  * Return value: read line on success, NULL on EOF.
  */
diff -upr a/dlib/dlib.h d/dlib/dlib.h
--- a/dlib/dlib.h	Tue Nov 11 13:06:16 2025
+++ d/dlib/dlib.h	Fri Dec  5 10:10:33 2025
@@ -188,6 +188,9 @@ void dLib_show_messages(bool_t show);
  */
 char *dGetcwd(void);
 char *dGethomedir(void);
+char *dGetsavedir(void);
+char *dGetenableunveil(void);
+void *dUnveil(const char *path, const char *perm);
 char *dGetline(FILE *stream);
 int dClose(int fd);
 int dUsleep(unsigned long us);
diff -upr a/src/dillo.cc d/src/dillo.cc
--- a/src/dillo.cc	Tue Nov 11 13:06:16 2025
+++ d/src/dillo.cc	Fri Dec  5 10:10:33 2025
@@ -493,7 +493,48 @@ int main(int argc, char **argv)
       fclose(fp);
    }
    dLib_show_messages(prefs.show_msg);
-
+   
+   // Use unveil
+   if (dGetenableunveil() != NULL) {
+      if (strncmp(dGetenableunveil(), "YES", 3) == 0) {
+         #ifdef ENABLE_UNVEIL
+	  const char *home = dGethomedir();
+         const char *save = prefs.save_dir;
+         int nsave = strlen(save);
+         int nhome = strlen(home);
+         if (nsave <= nhome) {
+            /* Prevent save_dir="/home" and save_dir=$HOME */
+            if (strncmp(save, home, nsave) == 0) {
+            MSG("save_dir cannot contain home\n");
+            exit(1);
+            }
+         }
+	  dUnveil("/bin/sh", "x");
+         dUnveil("/usr/local/share/fonts", "r");
+         dUnveil("/usr/local/share/icons", "r");
+         dUnveil("/usr/X11R6/share/X11/locale", "r");
+         dUnveil("/usr/X11R6/lib/X11/fonts", "r");
+         dUnveil("/usr/local/etc/dillo", "r");
+         dUnveil("/tmp", "rwc");
+         dUnveil("/usr/local/bin/dpid", "x");
+         dUnveil("/etc/fonts", "r");
+         dUnveil("/etc/resolv.conf", "r");
+         dUnveil("/etc/ssl/cert.pem", "r");
+         dUnveil(prefs.save_dir, "rwc");
+         char *dil_loc = dStrconcat(dGethomedir(), "/.dillo", NULL);
+         dUnveil(dil_loc, "rwc");
+         dFree(dil_loc);
+         char *icons_loc = dStrconcat(dGethomedir(), "/.icons", NULL);
+         dUnveil(icons_loc, "r");
+         dFree(icons_loc);
+         char *xauth_loc = dStrconcat(dGethomedir(), "/.Xauthority", NULL);
+         dUnveil(xauth_loc, "r");
+         dFree(xauth_loc);
+         dUnveil(NULL, NULL);
+         #endif
+      } 
+   }
+    
    // initialize internal modules
    a_Dpi_init();
    a_Dns_init();
