If you use the public folder installation method (the recommended and default) then all sensitive files and all executable files except index.php
will be outside the webroot, ensuring that they will never be returned or directly executed by the webserver even if the PHP or rewrite modules get disabled or removed.
The legacy method of putting all files in the webroot and protecting them with rewrite rules is supported by Flarum (as described under "customizing paths" in the documentation) but is inherently less secure due to depending on other modules being enabled, and this is probably what happened to you here.
Even then, the Flarum config file should only contain database credentials, which you should configure to only work when accessed from localhost, so even if an actor steals your database credentials, they cannot be used without also having shell access to the server.
The other secrets like the SMTP password are stored in the database and Flarum restricts their access only to admins. I remember discussing making password-like settings readonly in the admin panel to prevent them being stolen from a compromised admin account, but I don't believe we have implemented this yet. Some credential settings benefit from being readable for ease of troubleshooting.
As for how secure Flarum's code is, nothing is ever 100% secure, but I think our track record so far is pretty good 🙂