GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Codemod: request-data-write Semgrep · Issue #680 · pixee/codemodder-python

Codemod: request-data-write Semgrep #680

New issue
Copy link
New issue
Copy link
Open
Open
Codemod: request-data-write Semgrep#680
Copy link
Labels
new-codemodDescription for a new codemodDescription for a new codemodsemgrep

Description

@clavedeluna
clavedeluna
opened on Jul 1, 2024
Issue body actions

Running semgrep on pygoat

    ❯❱ python.django.security.injection.request-data-write.request-data-write
          Found user-controlled request data passed into '.write(...)'. This could be dangerous if a malicious
          actor is able to control data into sensitive files. For example, a malicious actor could force      
          rolling of critical log files, or cause a denial-of-service by using up available disk space.       
          Instead, ensure that request data is properly escaped or sanitized.                                 
          Details: https://sg.run/0Q6j                                                                        
                                                                                                              
           59┆ log_code = request.POST.get('log_code')
           60┆ api_code = request.POST.get('api_code')
           61┆ dirname = os.path.dirname(__file__)
           62┆ log_filename = os.path.join(dirname, "playground/A9/main.py")
           63┆ api_filename = os.path.join(dirname, "playground/A9/api.py")
           64┆ f = open(log_filename,"w")
           65┆ f.write(log_code)
            ⋮┆----------------------------------------
           60┆ api_code = request.POST.get('api_code')
           61┆ dirname = os.path.dirname(__file__)
           62┆ log_filename = os.path.join(dirname, "playground/A9/main.py")
           63┆ api_filename = os.path.join(dirname, "playground/A9/api.py")
           64┆ f = open(log_filename,"w")
           65┆ f.write(log_code)
           66┆ f.close()
           67┆ f = open(api_filename,"w")
           68┆ f.write(api_code)

We don't have an existing transformer that aligns with this. Could we just wrap arguments to open and write with escape or some other sanitization func?

Activity

  1. clavedeluna
    added
    new-codemodDescription for a new codemodDescription for a new codemod
    semgrep
    on Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    new-codemodDescription for a new codemodDescription for a new codemodsemgrep

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.