Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codemod: path-traversal-join Semgrep #685

Open
clavedeluna opened this issue Jul 1, 2024 · 0 comments
Open

Codemod: path-traversal-join Semgrep #685

clavedeluna opened this issue Jul 1, 2024 · 0 comments
Labels
new-codemod Description for a new codemod semgrep

Comments

@clavedeluna
Copy link
Contributor

running semgrep on pygoat

 ❯❱ python.django.security.injection.path-traversal.path-traversal-join.path-traversal-join
          Data from request is passed to os.path.join() and to open(). This is a path traversal vulnerability,
          which can lead to sensitive data being leaked. To mitigate, consider using os.path.abspath or       
          os.path.realpath or Path library.                                                                   
          Details: https://sg.run/Dovo                                                                        
                                                                                                              
          916┆ file=request.POST["blog"]
          917┆ try :
          918┆     dirname = os.path.dirname(__file__)
          919┆     filename = os.path.join(dirname, file)
          920┆     file = open(filename,"r")
          921┆     data = file.read()
          922┆     return render(request,"Lab/ssrf/ssrf_lab.html",{"blog":data})
          923┆ except:
          924┆     return render(request, "Lab/ssrf/ssrf_lab.html", {"blog": "No blog found"})
   

I don't believe we currently have a codemod for this pattern, but we could use deterministically try to implement the suggestion semgrep is giving us.

@clavedeluna clavedeluna added new-codemod Description for a new codemod semgrep labels Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-codemod Description for a new codemod semgrep
Projects
None yet
Development

No branches or pull requests

1 participant