Skip to content

Fix path traversal risk in ScorerModule temp file creation#10

Open
victor-nb wants to merge 1 commit intomainfrom
boost-advisor/fix-qyTLh7GB
Open

Fix path traversal risk in ScorerModule temp file creation#10
victor-nb wants to merge 1 commit intomainfrom
boost-advisor/fix-qyTLh7GB

Conversation

@victor-nb
Copy link
Copy Markdown

Summary

This PR fixes 1 security vulnerability identified by BoostSecurity.


Prevent path traversal in ScorerModule temp file creation in follow-recommendations-service/server/src/main/scala/com/twitter/follow_recommendations/modules/ScorerModule.scala (Line: 19)

Risk: fileFromResource wrote to a temp file created with user-influenced input (resource) which could enable path traversal/unsafe path handling patterns when untrusted input controls file paths, potentially overwriting arbitrary files.

Fix: Restricted resource to classpath entries under the expected STPScorerPath prefix, rejected .. sequences, handled missing resources, and used a safe fixed temp file prefix/suffix (instead of using resource as part of the filename) while ensuring streams are closed.

Review notes: Invalid or missing resources now throw IllegalArgumentException instead of failing later.


Generated by BoostSecurity Advisor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant