Gemfile require option allows you to require any file
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 4k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 81
Description
Describe the problem as clearly as you can
Within the Gemfile, you can do:
gem 'foo', require: ["foo", "foo/some/other/file/in/gem"]
This is useful if you want to automatically require some other entrypoint for the gem.
Today, I just realized that this simply passes the value to Kernel.require, which means you can require any file in the filesystem.
gem 'foo', require: ["/some/ruby/file/in/fs", "../../../some/other/file/relative/to/path"]
It seems intuitive if the files that you require in the gem directive are scoped to that gem. I'm not sure if this is a vulnerability since it's code that you own/written, but I think a little lockdown here would be good. Ideally, whatever is passed through to require: [...] is validated and appended to the gem's path. The validation would simply not allow a final (computed) path in require that is outside the gem's path.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Gemfile gem directive and trace how its require option reaches Kernel.require. Determine how the requested path should be validated against the gem's path, including absolute and relative paths; done means out-of-scope files are rejected while valid gem entrypoints still load.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100