T09 · Insecure Skill Coding Practices
- Location
submit_backtest.py:31- Finding
Automatic Upload of Unselected Sibling Data Files
- Content
View full analysis
Vulnerability Details
File Location:
submit_backtest.py:31-41
Vulnerability Type: Excessive local file collection and unintended network disclosure
Risk Level: MediumVulnerable Code
python # 2. Optionally add other relevant files in the same directory (excluding .py files to avoid conflicts) valid_data_extensions = {'.json', '.txt', '.csv'} for file in os.listdir(base_dir): ext = os.path.splitext(file)[1] if ext in valid_data_extensions: full_path = os.path.join(base_dir, file) try: with open(full_path, 'r', encoding='utf-8') as f: content = f.read() files_list.append({'name': file, 'content': content}) print(f"Added data file: {file}") except Exception as e: print(f"Skipping data file {file}: {e}")Technical Analysis
The submission process enumerates the strategy file's entire parent directory and automatically reads every file whose extension is
.json,.txt, or.csv. These files are subsequently passed toQCApiClient.update_project_files()and uploaded to the configured QuantConnect cloud project.The implementation does not require users to select auxiliary files explicitly and provides no confirmation step, filename allowlist, content sensitivity check, file-size limit, or upload manifest approval. File extensions alone do not establish that a file is necessary for the backtest. Such files may contain API credentials, proprietary datasets, customer information, trading records, or unrelated configuration data.
Although uploading explicitly selected strategy resources is part of the declared functionality, automatically collecting every matching sibling file exceeds the minimum local file access required.
Attack Path
- A user stores or selects a strategy in a directory containing unrelated
.json,.txt, or.csvfiles. - The user invokes `submit_backtest.p ...[truncated 1199 chars]
- A user stores or selects a strategy in a directory containing unrelated
- Remediation
View remediation
Remediation Suggestions
- Upload only the file supplied through
--main-fileby default. - Add a repeatable explicit option such as
--data-file path/to/file.csvfor each required auxiliary file. - Resolve each supplied path with
os.path.realpath()and verify that it is a regular file in an approved directory. - Display a complete upload manifest, including filenames and sizes, before initiating network transmission.
- Require affirmative confirmation for auxiliary uploads in interactive use and provide an explicit non-interactive approval flag for automation.
- Enforce per-file and aggregate upload-size limits.
- Reject symbolic links unless their resolved targets have been explicitly approved.
- Document precisely which local files will be read and uploaded.
- Upload only the file supplied through
