How to fix security issue in Dradis where Ruby Rails Mini Profiler "Rack Environment" is enabled and visible when using pp=env

I'm not familiar with Ruby, Rails, Puma, or anything else in the Ruby environment, although I'm well familiar with other programming environments which are similar. Still, it took me longer to install Dradis than it should have, and I finally gave up on the Docker version entirely. I had to cobble together a systemd service knowing nothing about "bundle exec" or "puma." It was much uglier than it should be, leaving me with only one question once it was up and running: why are people who program with Ruby stuck in the 1990s? In my humble opinion, PHP is a simple and uncomplicated joy to work with compared to Ruby.

A few days later, I received an alert from my regular external security scan telling me there was a web page on my new Dradis site displaying internal network information. It was an unpleasant surprise which I would have been able to fix within minutes in my native world, but took me most of a day to track down and resolve. I'm going to skip a lot of me trawling through code, documentation, and forum discussions which got me to the heart of the matter:

  1. The current version of Dradis (CE) comes out of the box in development mode. This is fairly reasonable for a community edition.
  2. The development mode code profiler is enabled. Although appropriate for developers, this is a serious security risk in production because it displays a webpage full of internal network information and lots of information about your program.
  3. When you figure out how to get Dradis into production mode, it doesn't solve the problem.
  4. When you figure out how to configure the profiler into authorized-viewers-only mode, the problem remains.
  5. When you hack the code (profiler.rb) to outright disable the profiler within its own codebase, the problem remains.
  6. When you disable the profiler in config.rb, it finally stops printing a vast array of internal network information to the world.
  7. Yeah, yeah, I should have gone right to that file first, but remember I have no idea where things are in this environment.

Here's the problem:

After Dradis is installed, if you visit the main URL with pp=env appended, like so:

https://dradis.exampledomain.com/?pp=env

You'll get a "Rack Environment" page which shows all kinds of details about your server, your application, and your network environment. It looks like this:

Rack Environment
---------------
rack.version: [1, 6]
rack.errors: #<IO:0x00007fc17d853bd0>
rack.multithread: true
rack.multiprocess: false
rack.run_once: false
rack.url_scheme: https
SCRIPT_NAME: 
QUERY_STRING: pp=env
SERVER_SOFTWARE: puma 6.4.3 The Eagle of Durango
GATEWAY_INTERFACE: CGI/1.2
REQUEST_METHOD: GET
REQUEST_PATH: /
REQUEST_URI: /?pp=env
SERVER_PROTOCOL: HTTP/1.1
HTTP_HOST: localhost:3001
HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.5
HTTP_ACCEPT_ENCODING: gzip, deflate, br, zstd
HTTP_DNT: 1
HTTP_SEC_GPC: 1
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_SEC_FETCH_DEST: document
HTTP_SEC_FETCH_MODE: navigate
HTTP_SEC_FETCH_SITE: none
HTTP_SEC_FETCH_USER: ?1
HTTP_PRIORITY: u=0, i
HTTP_X_FORWARDED_PROTO: https
HTTP_X_FORWARDED_SSL: on
HTTP_X_FORWARDED_FOR: 172.127.132.118
HTTP_X_FORWARDED_HOST: dradis.exampledomain.com
HTTP_X_FORWARDED_SERVER: dradis.exampledomain.com
HTTP_CONNECTION: Keep-Alive
puma.request_body_wait: 0.00633201003074646
SERVER_NAME: localhost
SERVER_PORT: 3001
PATH_INFO: /
REMOTE_ADDR: 127.0.0.1
HTTP_VERSION: HTTP/1.1
puma.socket: #<TCPSocket:0x00007fc1530c7a30>
rack.hijack?: true
rack.hijack: #<Puma::Client:0x00007fc1530c79e0>
rack.input: #<Puma::NullIO:0x00007fc17a1508b8>
rack.after_reply: []
puma.config: #<Puma::Configuration:0x00007fc17a107398>
action_dispatch.parameter_filter: [:password, :password_confirmation, :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn]
action_dispatch.redirect_filter: []
action_dispatch.secret_key_base: 0f75bcdc814e320bc54a9d0b3615081ea0850a3aa9ceffaf19fda97ad475d66bc37afc80f9fc3bccb774e3bb95f634b917b91e6997069b81faa4993421f14889
.
.
.

Environment
---------------
USER: <username>
BUNDLER_VERSION: 2.3.16
SHLVL: 0
RUBYOPT: -r/home/<username>/dradis/dradis-ce/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.16/lib/bundler/setup
SERVER: puma
HOME: /home/<username>
RBENV_ROOT: /home/<username>/.rbenv
BUNDLER_ORIG_BUNDLER_VERSION: 2.3.16
SYSTEMD_EXEC_PID: 464841
LOGNAME: <username>
RUBYLIB: /home/<username>/dradis/dradis-ce/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.16/lib:/home/<username>/.rbenv/rbenv.d/exec/gem-rehash
PATH: /home/<username>/dradis/dradis-ce/vendor/bundle/ruby/3.1.0/bin:/home/<username>/.rbenv/versions/3.1.2/bin:/home/<username>/.rbenv/libexec:/home/<username>/.rbenv/plugins/ruby-build/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
INVOCATION_ID: 50790fd5c0df419f83cfd8e4470f53a7
.
.
.

This example is truncated, the actual output is much longer. There are other pp= features which expose even more information. You get the idea. The fact that this is running in a user's home directory instead of /opt, the username, ruby and tool versions, all kinds of things which should not be visible to the public.

The fix:

Edit the following file: ./dradis/dradis-ce/vendor/bundle/ruby/3.1.0/gems/rack-mini-profiler-2.3.0/lib/mini_profiler/config.rb

nano ./dradis/dradis-ce/vendor/bundle/ruby/3.1.0/gems/rack-mini-profiler-2.3.0/lib/mini_profiler/config.rb

In the following section which is a few lines down in the file, comment out the "@enabled=true" line and add the line you see in red below:

# called after rack chain, to ensure we are REALLY allowed to profile
@skip_schema_queries    = false
@storage                = MiniProfiler::MemoryStore
@user_provider          = Proc.new { |env| Rack::Request.new(env).ip }
#changing to allow_authorized did not work:
#@authorization_mode     = :allow_all
@authorization_mode     = :allow_authorized
@backtrace_threshold_ms = 0
@flamegraph_sample_rate = 0.5
@storage_failure = Proc.new do |exception|
  if @logger
    @logger.warn("MiniProfiler storage failure: #{exception.message}")
  end
end
#set enabled to false
#@enabled = true
@enabled = false
.
.
.

The first section marked in bold should have worked, but it didn't. The second section marked in bold worked: set @enabled=false. Restart the application. Now when people try that URL or any of the other pp flags, the application ignores the request and takes you straight to the login page.

I know, I know, the right way to fix this is to figure out why production mode isn't working, and fix that, but I spent an enormous amount of time finding this fix, and need to get on with things. Anyone with advice on how to fix the production mode fail, lemme know in comments below.

Note there may have been a cache which was causing some of my previous legit fixes to fail, but this fix seems to bypass any cache, and it just worked.

Have fun.

 

Eramba System Health Check fails immediately after installation due to cron error but really it's an .env file issue

System Health Warning: This installation of eramba has a few issues in order to work properly. Check on the settings page under health monitor what could be the issues or click here

The .env file for an eramba installation cannot have #comments. If you have comments, it will silently fail, and you'll see this error message: "System Health Warning: This installation of eramba has a few issues in order to work properly. Check on the settings page under health monitor what  […]

Continue reading

How to open files in vscodium using link in a browser to vscode: add a registry key

To open up a file within a browser having a vscode://file/ URL like this: vscode://file/C:\xampp\htdocs\mycoolapp\app\Models\Membership.php So it looks like this:   Then save the following as a registry file named vscode.reg: Windows Registry Editor Version 5.00  […]

Continue reading

How to fix the multiple monitor resize after lock screen issue in PopOS and Ubuntu Linux with GNOME

TL;DR Quick Fix is at the END for people who want to get to the deets w/o prolegomenon. I put as many keywords as I could into the headline so this post is easy for others to find. Although I'm not a gamer, I have a super duper Lenovo Legion gamer laptop with all kinds of nVidia power for my daily  […]

Continue reading

Euclid's clever solution to the problems of the void and the infinitesimal

Euclid's Definition 1 We normally think of a geometrical point as being smaller than anything, because of where Euclid placed it in the hierarchy of geometry. Building up from simple to more complex, his first definition is the simplest: "A point is that which has no part." Clearly, Euclid  […]

Continue reading

A way of understanding true ternary logic which includes the continuum and reveals the importance of the word AND

Introducing true ternary Ternary logic is introduced at Wikipedia like this: In logic, a three-valued logic (also trinary logic, trivalent, ternary, or trilean, sometimes abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating true, false, and  […]

Continue reading

Thinking about a rare opposite of Schadenfreude which is neither Freudefreude nor Mudita but Schadenmitgefühl

Schadenfreude: it's not just for humans

The wild headline is intentional because the audience for this article will most likely arrive here by search engines, as people are trying to find "the opposite of schadenfreude," but not the obvious opposite. Of these visitors only a few will appreciate this little word adventure here,  […]

Continue reading

Allow the Deep to Speak

This article is going to be stored in a database with a record ID of 281, which is a prime number, as soon as I click "Save." At the moment that I write these introductory words, it exists in an aether of nowhere. Neither here nor there. It has no record ID. It is thus a virtual weblog  […]

Continue reading

What to do when Roundcube says: Decryption failed: Key password required, and: Could not decrypt this message

Roundcube error: Decryption failed: Key password required.

Roundcube is great. Easy to get up and running, but it surprises me that I couldn't find the following solution online, so I'm making a post here. When you receive an email (say, from a public key generator) that is encrypted by your own PRIVATE key and you haven't fully configured encryption, it  […]

Continue reading

A whole new way into heart meditation reveals... light... on Thanksgiving morning

A year of mindful[1] meditation Here it is early the morning of Thanksgiving 2023 and I just discovered a rather deep heartful meditation which took about a year to learn. The essential idea is quite simple and took only a few minutes to comprehend, but it took a year of preparation so that I could  […]

Continue reading

"I want to break this apart and put it back together again" -- while trying to solve the Rubik's cube

Rubik's cube

This is a weblog post about what makes a hacker, and why there are "good" hackers and "bad" hackers (which is about quality, not whitehat vs blackhat), an insight I discovered while in a brief conversation with my 10-year-old daughter. My daughter has discovered the Rubik's cube,  […]

Continue reading

Awaken the deep: insights from a meditative adventure on the nature of Speaking and Being

The Deep

First, a brief summary. This morning during meditation I was deep in my heart, listening, when I found myself arriving into a rare condition of clarity. It seemed to me as though I had entered a holy place within my soul, where the veil between heaven and earth is fading. My attention was in a  […]

Continue reading

How to visualize gravity correctly

This is not how gravity works

First, how to visualize gravity incorrectly   Gravity is illustrated incorrectly in almost all images published over the past century, ever since Einstein determined how gravity works. Only a few artists get it right, while hundreds of books and websites explaining gravity show visually compelling  […]

Continue reading

Discovering David Wray and not realizing he was the conductor, and thereby seeing a window into sublime joy

The longer I listen to classical music, the deeper grows my ability to discern a depth of quality which I previously missed. I grow hungry for that depth -- or is it a height? -- of quality, and suffer through many mediocre performances in search of the gorgeous ones. And then I find one and am  […]

Continue reading

The binary perceptive lens is not for the purpose of dividing everything, but for the purpose of uniting everything

A recent essay where I invented the word trivulet as the name of the fundamental ternary logic element ended up becoming a fertile field for new insights. This is now the second post derived from ideas discovered while writing that one. While explaining how ternary logic is different from binary  […]

Continue reading

Page top