René's URL Explorer Experiment


Title: [SECURITY] Fix Temporary Directory Hijacking or Information Disclosure Vulnerability by JLLeitschuh · Pull Request #443 · scijava/scijava-common · GitHub

Open Graph Title: [SECURITY] Fix Temporary Directory Hijacking or Information Disclosure Vulnerability by JLLeitschuh · Pull Request #443 · scijava/scijava-common

X Title: [SECURITY] Fix Temporary Directory Hijacking or Information Disclosure Vulnerability by JLLeitschuh · Pull Request #443 · scijava/scijava-common

Description: Security Vulnerability Fix This pull request fixes either 1.) Temporary Directory Hijacking Vulnerability, or 2.) Temporary Directory Information Disclosure Vulnerability, which existed in this project. Preamble The system temporary directory is shared between all users on most unix-like systems (not MacOS, or Windows). Thus, code interacting with the system temporary directory must be careful about file interactions in this directory, and must ensure that the correct file permissions are set. This PR was generated because the following chain of calls was detected in this repository in a way that leaves this project vulnerable. File.createTempFile(..) -> file.delete() -> either file.mkdir() or file.mkdirs(). Impact This vulnerability can have one of two impacts depending upon which vulnerability it is. Temporary Directory Information Disclosure - Information in this directory is visable to other local users, allowing a malicious actor co-resident on the same machine to view potentially sensitive files. Temporary Directory Hijacking Vulnerability - Same impact as 1. above, but also, ther local users can manipulate/add contents to this directory. If code is being executed out of this temporary directory, it can lead to local priviledge escalation. Temporary Directory Hijacking This vulnerability exists because the return value from file.mkdir() or file.mkdirs() is not checked to determine if the call succeeded. Say, for example, because another local user created the directory before this process. File tmpDir = File.createTempFile("temp", ".dir"); // Attacker knows the full path of the directory that will be later created // delete the file that was created tmpDir.delete(); // Attacker sees file is deleted and begins a race to create their own directory before the java code. // and makes a directory of the same name // SECURITY VULNERABILITY: Race Condition! - Attacker beats java code and now owns this directory tmpDir.mkdirs(); // This method returns 'false' because it was unable to create the directory. No exception is thrown. // Attacker can write any new files to this directory that they wish. // Attacker can read any files created within this directory. Other Examples CVE-2021-20202 - Keycloak/Keycloak CVE-2020-27216 - eclipse/jetty.project Temporary Directory Information Disclosure This vulnerability exists because, although the return values of file.mkdir() or file.mkdirs() are correctly checked, the permissions of the directory that is created follows the default system uname settings. Thus, the directory is created with everyone-readable permissions. As such, any files/directories written into this directory are viewable by all other local users on the system. File tmpDir = File.createTempFile("temp", ".dir"); tmpDir.delete(); if (!tmpDir.mkdirs()) { // Guard correctly prevents temporary directory hijacking, but directory contents are everyone-readable. throw new IOException("Failed to create temporary directory"); } Other Examples CVE-2020-15250 - junit-team/junit CVE-2021-21364 - swagger-api/swagger-codegen CVE-2022-24823 - netty/netty CVE-2022-24823 - netty/netty The Fix The fix has been to convert the logic above to use the following API that was introduced in Java 1.7. File tmpDir = Files.createTempDirectory("temp dir").toFile(); The API both created the directory securely, ie with a random, non-conflicting name, with directory permissions that only allow the currently executing user to read or write the contents of this directory. ➡️ Vulnerability Disclosure ⬅️ 👋 Vulnerability disclosure is a super important part of the vulnerability handling process and should not be skipped! This may be completely new to you, and that's okay, I'm here to assist! First question, do we need to perform vulnerability disclosure? It depends! Is the vulnerable code only in tests or example code? No disclosure required! Is the vulnerable code in code shipped to your end users? Vulnerability disclosure is probably required! Vulnerability Disclosure How-To You have a few options options to perform vulnerability disclosure. However, I'd like to suggest the following 2 options: Request a CVE number from GitHub by creating a repository-level GitHub Security Advisory. This has the advantage that, if you provide sufficient information, GitHub will automatically generate Dependabot alerts for your downstream consumers, resolving this vulnerability more quickly. Reach out to the team at Snyk to assist with CVE issuance. They can be reached at the Snyk's Disclosure Email. Detecting this and Future Vulnerabilities This vulnerability was automatically detected by GitHub's LGTM.com using this CodeQL Query. You can automatically detect future vulnerabilities like this by enabling the free (for open-source) GitHub Action. I'm not an employee of GitHub, I'm simply an open-source security researcher. Source This contribution was automatically generated with an OpenRewrite refactoring recipe, which was lovingly hand crafted to bring this security fix to your repository. The source code that generated this PR can be found here: UseFilesCreateTempDirectory Opting-Out If you'd like to opt-out of future automated security vulnerability fixes like this, please consider adding a file called .github/GH-ROBOTS.txt to your repository with the line: User-agent: JLLeitschuh/security-research Disallow: * This bot will respect the ROBOTS.txt format for future contributions. Alternatively, if this project is no longer actively maintained, consider archiving the repository. CLA Requirements This section is only relevant if your project requires contributors to sign a Contributor License Agreement (CLA) for external contributions. It is unlikely that I'll be able to directly sign CLAs. However, all contributed commits are already automatically signed-off. The meaning of a signoff depends on the project, but it typically certifies that committer has the rights to submit this work under the same license and agrees to a Developer Certificate of Origin (see https://developercertificate.org/ for more information). - Git Commit Signoff documentation If signing your organization's CLA is a strict-requirement for merging this contribution, please feel free to close this PR. Sponsorship & Support This contribution is sponsored by HUMAN Security Inc. and the new Dan Kaminsky Fellowship, a fellowship created to celebrate Dan's memory and legacy by funding open-source work that makes the world a better (and more secure) place. This PR was generated by Moderne, a free-for-open source SaaS offering that uses format-preserving AST transformations to fix bugs, standardize code style, apply best practices, migrate library versions, and fix common security vulnerabilities at scale. Tracking All PR's generated as part of this fix are tracked here: JLLeitschuh/security-research#10

Open Graph Description: Security Vulnerability Fix This pull request fixes either 1.) Temporary Directory Hijacking Vulnerability, or 2.) Temporary Directory Information Disclosure Vulnerability, which existed in this pro...

X Description: Security Vulnerability Fix This pull request fixes either 1.) Temporary Directory Hijacking Vulnerability, or 2.) Temporary Directory Information Disclosure Vulnerability, which existed in this pro...

Opengraph URL: https://github.com/scijava/scijava-common/pull/443

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7d6d8d85-8904-d28b-b006-2683c229ca4e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id89A6:C8A64:CCB2B5:11A45F8:696A8E80
html-safe-nonce47ae23165ff1ba018c7d0af6e4bb5a95b4ba14dbd2d83f5c7f5dde7dbd0d8f68
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OUE2OkM4QTY0OkNDQjJCNToxMUE0NUY4OjY5NkE4RTgwIiwidmlzaXRvcl9pZCI6IjQ1NDU0NzQyOTc1NTQ3MDE5NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacce4145f4ea23a6e1c04bed54742d21ab610c5fc3124deec01c546a8187a2cf0a
hovercard-subject-tagpull_request:1020990767
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/scijava/scijava-common/pull/443/files
twitter:imagehttps://avatars.githubusercontent.com/u/1323708?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1323708?s=400&v=4
og:image:altSecurity Vulnerability Fix This pull request fixes either 1.) Temporary Directory Hijacking Vulnerability, or 2.) Temporary Directory Information Disclosure Vulnerability, which existed in this pro...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4dd496afc954da9c207b2d9fbe86e3074619f565754aa1d9274aec30d9e5b8d7
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/scijava/scijava-common git https://github.com/scijava/scijava-common.git
octolytics-dimension-user_id1262770
octolytics-dimension-user_loginscijava
octolytics-dimension-repository_id3594497
octolytics-dimension-repository_nwoscijava/scijava-common
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id3594497
octolytics-dimension-repository_network_root_nwoscijava/scijava-common
turbo-body-classeslogged-out env-production page-responsive
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release31496a13b80a2f6ad77d6c617ee2255a3545b539
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/scijava/scijava-common/pull/443/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fscijava%2Fscijava-common%2Fpull%2F443%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fscijava%2Fscijava-common%2Fpull%2F443%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=scijava%2Fscijava-common
Reloadhttps://github.com/scijava/scijava-common/pull/443/files
Reloadhttps://github.com/scijava/scijava-common/pull/443/files
Reloadhttps://github.com/scijava/scijava-common/pull/443/files
scijava https://github.com/scijava
scijava-commonhttps://github.com/scijava/scijava-common
Notifications https://github.com/login?return_to=%2Fscijava%2Fscijava-common
Fork 53 https://github.com/login?return_to=%2Fscijava%2Fscijava-common
Star 90 https://github.com/login?return_to=%2Fscijava%2Fscijava-common
Code https://github.com/scijava/scijava-common
Issues 169 https://github.com/scijava/scijava-common/issues
Pull requests 16 https://github.com/scijava/scijava-common/pulls
Actions https://github.com/scijava/scijava-common/actions
Projects 0 https://github.com/scijava/scijava-common/projects
Wiki https://github.com/scijava/scijava-common/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/scijava/scijava-common/security
Please reload this pagehttps://github.com/scijava/scijava-common/pull/443/files
Insights https://github.com/scijava/scijava-common/pulse
Code https://github.com/scijava/scijava-common
Issues https://github.com/scijava/scijava-common/issues
Pull requests https://github.com/scijava/scijava-common/pulls
Actions https://github.com/scijava/scijava-common/actions
Projects https://github.com/scijava/scijava-common/projects
Wiki https://github.com/scijava/scijava-common/wiki
Security https://github.com/scijava/scijava-common/security
Insights https://github.com/scijava/scijava-common/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fscijava%2Fscijava-common%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fscijava%2Fscijava-common%2Fissues%2Fnew%2Fchoose
JLLeitschuhhttps://github.com/JLLeitschuh
scijava:masterhttps://github.com/scijava/scijava-common/tree/master
BulkSecurityGeneratorProjectV2:fix/JLL/temporary_directory_hijacking_or_temporary_directory_information_disclosurehttps://github.com/BulkSecurityGeneratorProjectV2/scijava__scijava-common/tree/fix/JLL/temporary_directory_hijacking_or_temporary_directory_information_disclosure
Conversation 2 https://github.com/scijava/scijava-common/pull/443
Commits 1 https://github.com/scijava/scijava-common/pull/443/commits
Checks 0 https://github.com/scijava/scijava-common/pull/443/checks
Files changed https://github.com/scijava/scijava-common/pull/443/files
Please reload this pagehttps://github.com/scijava/scijava-common/pull/443/files
[SECURITY] Fix Temporary Directory Hijacking or Information Disclosure Vulnerability https://github.com/scijava/scijava-common/pull/443/files#top
Show all changes 1 commit https://github.com/scijava/scijava-common/pull/443/files
933967f vuln-fix: Temporary Directory Hijacking or Information Disclosure JLLeitschuh Aug 9, 2022 https://github.com/scijava/scijava-common/pull/443/commits/933967fd36428c7d2a11cd447527f45b37593ca6
Clear filters https://github.com/scijava/scijava-common/pull/443/files
Please reload this pagehttps://github.com/scijava/scijava-common/pull/443/files
Please reload this pagehttps://github.com/scijava/scijava-common/pull/443/files
src/main/java/org/scijava/util/FileUtils.javahttps://github.com/scijava/scijava-common/pull/443/files#diff-a917a970d906a657bc4994e712f9e76cbe248b7cb056ece6675687b35ad78d74
View file https://github.com/scijava/scijava-common/blob/933967fd36428c7d2a11cd447527f45b37593ca6/src/main/java/org/scijava/util/FileUtils.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/scijava/scijava-common/pull/443/{{ revealButtonHref }}
https://github.com/scijava/scijava-common/pull/443/files#diff-a917a970d906a657bc4994e712f9e76cbe248b7cb056ece6675687b35ad78d74
https://github.com/scijava/scijava-common/pull/443/files#diff-a917a970d906a657bc4994e712f9e76cbe248b7cb056ece6675687b35ad78d74
https://github.com/scijava/scijava-common/pull/443/files#diff-a917a970d906a657bc4994e712f9e76cbe248b7cb056ece6675687b35ad78d74
https://github.com/scijava/scijava-common/pull/443/files#diff-a917a970d906a657bc4994e712f9e76cbe248b7cb056ece6675687b35ad78d74
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.