spatie / laravel-ignition

A beautiful error page for Laravel apps
https://flareapp.io/ignition
MIT License
460 stars 68 forks source link

Cannot run solution in this environment #81

Closed Messhias closed 2 years ago

Messhias commented 2 years ago

This is just happening after the last update:

note: this is in the production environment.

{
    "class": "Spatie\\LaravelIgnition\\Exceptions\\CannotExecuteSolutionForNonLocalEnvironment",
    "message": "Cannot run solution in this environment",
    "code": 0,
    "file": "/var/www/vendor/spatie/laravel-ignition/src/Exceptions/CannotExecuteSolutionForNonLocalEnvironment.php:14",
    "trace": [
        "/var/www/vendor/spatie/laravel-ignition/src/Http/Controllers/ExecuteSolutionController.php:33",
        "/var/www/vendor/spatie/laravel-ignition/src/Http/Controllers/ExecuteSolutionController.php:20",
        "/var/www/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:48",
        "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php:261",
        "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php:204",
        "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:725",
        "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:141",
        "/var/www/vendor/spatie/laravel-ignition/src/Http/Middleware/RunnableSolutionsEnabled.php:15",
        "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:180",
        "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:116",
        "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:727",
        "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:702",
        "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:666",
        "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:655",
        "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:167",
        "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:141",
        "/var/www/vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestIpMiddleware.php:45",
        "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:180",
        "/var/www/vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http

composer.json:

{
  "name": "laravel/laravel",
  "type": "project",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "require": {
    "php": "^8.1",
    "ext-curl": "*",
    "ext-json": "*",
    "ext-openssl": "*",
    "ext-pdo": "*",
    "aws/aws-sdk-php-laravel": "~3.0",
    "darkaonline/l5-swagger": "^8.0",
    "doctrine/dbal": "^3.1",
    "fruitcake/laravel-cors": "^3.0",
    "gamegos/jws": "^1.0",
    "goetas-webservices/xsd-reader": "^0.3.6",
    "guzzlehttp/guzzle": "^7.0.1",
    "intervention/image": "^2.5",
    "laravel/framework": "^9.0",
    "laravel/octane": "^1.2",
    "laravel/telescope": "^4.7",
    "laravel/tinker": "^2.5",
    "league/flysystem-aws-s3-v3": "^3.0",
    "maatwebsite/excel": "^3.1",
    "monarobase/country-list": "^3.2",
    "namshi/jose": "^7.2",
    "owen-it/laravel-auditing": "^13.0",
    "php-open-source-saver/jwt-auth": "^1.1",
    "phpseclib/phpseclib": "^3.0",
    "predis/predis": "^1.1",
    "pusher/pusher-php-server": "^7.0",
    "s-ichikawa/laravel-sendgrid-driver": "^4.0",
    "scotteh/php-goose": "^1.1",
    "sentry/sentry-laravel": "^2.11",
    "spatie/laravel-ignition": "^1.0",
    "thedoctor0/laravel-mailjet-driver": "1.0.4",
    "twilio/sdk": "^6.34",
    "vlucas/phpdotenv": "^5.2",
    "voku/portable-utf8": "^6.0",
    "voku/simple_html_dom": "^4.7",
    "web-token/jwt-easy": "^2.2",
    "web-token/jwt-key-mgmt": "^2.2",
    "web-token/jwt-signature": "^2.2",
    "web-token/jwt-signature-algorithm-rsa": "^2.2",
    "zircote/swagger-php": "^3.0"
  },
  "require-dev": {
    "barryvdh/laravel-ide-helper": "^2.9",
    "fakerphp/faker": "^1.13",
    "kitloong/laravel-migrations-generator": "^5.0",
    "mockery/mockery": "^1.3.1",
    "nunomaduro/collision": "^6.1",
    "phpunit/phpunit": "^9.5"
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
  },
  "extra": {
    "laravel": {
      "dont-discover": []
    }
  },
  "autoload": {
    "psr-4": {
      "App\\": "app/",
      "Database\\Factories\\": "database/factories/",
      "Database\\Seeders\\": "database/seeds"
    },
    "classmap": [
      "database/seeds"
    ],
    "files": [
      "app/helpers.php"
    ]
  },
  "autoload-dev": {
    "psr-4": {
      "Tests\\": "tests/"
    }
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "scripts": {
    "post-autoload-dump": [
      "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
      "@php artisan package:discover --ansi"
    ],
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "@php artisan key:generate --ansi"
    ]
  }
}
AlexVanderbist commented 2 years ago

Hi @Messhias, please make sure that debug mode is turned off (APP_DEBUG=false) in your production environment. Additionally, please also make sure that the IGNITION_ENABLE_RUNNABLE_SOLUTIONS environment variable is either not set or set to false!

If debug mode is turned off and IGNITION_ENABLE_RUNNABLE_SOLUTIONS is not set, please make sure that config('ignition.enable_runnable_solutions') is not enabled. You can test this in Laravel Tinker on your production server.

LucianMihalache commented 2 years ago

Hi @Messhias, please make sure that debug mode is turned off (APP_DEBUG=false) in your production environment. Additionally, please also make sure that the IGNITION_ENABLE_RUNNABLE_SOLUTIONS environment variable is either not set or set to false!

If debug mode is turned off and IGNITION_ENABLE_RUNNABLE_SOLUTIONS is not set, please make sure that config('ignition.enable_runnable_solutions') is not enabled. You can test this in Laravel Tinker on your production server.

I am facing the same issue, sometimes on my dev environment [APP_ENV=development] I receive this error. The APP_DEBUG=true and the IGNITION_ENABLE_RUNNABLE_SOLUTIONS is not set in the .env.

I see in the code that the ExecuteSolutionController checks if the environment is a local environment

if (! app()->environment('local')) {
    throw CannotExecuteSolutionForNonLocalEnvironment::make();
}

Can we change this from if not local to if production? Because that is the place where we should not show the error page.

Messhias commented 2 years ago

Hi @Messhias, please make sure that debug mode is turned off (APP_DEBUG=false) in your production environment. Additionally, please also make sure that the IGNITION_ENABLE_RUNNABLE_SOLUTIONS environment variable is either not set or set to false!

If debug mode is turned off and IGNITION_ENABLE_RUNNABLE_SOLUTIONS is not set, please make sure that config('ignition.enable_runnable_solutions') is not enabled. You can test this in Laravel Tinker on your production server.

This doesn't make sense, why I should turn off the ignition in any environment?

psprokofiev commented 2 years ago

I have same errors in buglog, here is my config

APP_ENV=development
APP_DEBUG=true

so, there is not production

kwarnkham commented 2 years ago

Got same issue. I don't want to turn off debug in production. I want to know what's wrong so I can fix.

LucianMihalache commented 2 years ago

So, looking at the code, the only way to get rid of this, is to set the environment to "local".

My opinion is that this should be toggled not by the environment, but by an enable/disable config.

Messhias commented 2 years ago

So, looking at the code, the only way to avoid this is to set the environment to "local".

My opinion is that this should be toggled not by the environment, but by an enable/disable config.

Yes, there's a PR to fix that?

Messhias commented 2 years ago

@AlexVanderbist I created a PR to fix the issue.

Messhias commented 2 years ago

So, looking at the code, the only way to get rid of this is to set the environment to "local".

My opinion is that this should be toggled not by the environment, but by an enable/disable config.

I created a PR to fix that.

Messhias commented 2 years ago

@AlexVanderbist I created a PR to fix the issue.

There's someone else in this repository who's a maintainer too?

freekmurze commented 2 years ago

Thanks for the PR. Please have some patience, we'll get to this PR when we have some time.

AlexVanderbist commented 2 years ago

Hi there! Thanks for your patience and for the PR.

Running solutions is disabled on non-local environments (regardless of APP_DEBUG) because a lot of people new to the framework tend to deploy their applications with APP_DEBUG turned on. This would then possibly expose them to remote code execution through the execute solutions endpoint (or other debug features).

I agree that there should be a way to override this behaviour. #98 adds an additional environment variable to bypass the local environment check. However, I think that will be confusing as there's already a IGNITION_ENABLE_RUNNABLE_SOLUTIONS environment variable. I'll try to open a PR in a minute that allows IGNITION_ENABLE_RUNNABLE_SOLUTIONS=true to bypass the local environment check regardless of APP_DEBUG.

Finally, sort of offtopic:

@kwarnkham:

Got same issue. I don't want to turn off debug in production. I want to know what's wrong so I can fix.

I would really advice against this. Running any Laravel app publicly in debug mode will get you in trouble. There are malicious scrapers constantly looking for exposed applications to abuse debug features in this package and others.

AlexVanderbist commented 2 years ago

Hi again, when #111 is merged and tagged, you should be able to set IGNITION_ENABLE_RUNNABLE_SOLUTIONS=true to allow runnable solutions everywhere, regardless of environment.

thequickcode commented 1 year ago

I'm just coming here to say thank you guys for disabling command executing on production env by default.

I forgot to turn off debugging on production and seems like somebody tried to do some bad stuff on my website, but execution was blocked on production.

THANK YOU!