Scala Unsafe Input Resource Injection
Description
Detects unsafe resource access patterns in Scala Play Framework applications where user-controlled input could be used to access files or resources. This could allow attackers to access unauthorized files or resources through path traversal attacks.
Detection Strategy
• Checks if Play Framework MVC components are imported in the code
• Identifies usage of Environment class and captures environment variable references
• Looks for calls to suspicious resource access methods like getFile(), getResource()
• Verifies if method arguments contain or are influenced by user-controlled input
• Reports a vulnerability when suspicious resource access methods are called with potentially tainted input
Vulnerable code example
package controllers
import javax.inject._
import play.api.mvc._
import play.api.Environment
@Singleton
class ResourceController @Inject()(env: Environment, cc: ControllerComponents) extends AbstractController(cc) {...✅ Secure code example
package controllers
import javax.inject._
import play.api.mvc._
import play.api.Environment
@Singleton
class ResourceController @Inject()(env: Environment, cc: ControllerComponents) extends AbstractController(cc) {...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.