Skip to content

Conversation

@haoliuu
Copy link
Collaborator

@haoliuu haoliuu commented Feb 9, 2026

Implements Fuzzing Test for AI Dev Gallery. This PR introduces a new fuzzing project to the solution, focused on improving the robustness and security for the app. It adds a new .NET project for fuzz testing, defines fuzzing targets for protocol handlers and URL parsers, provides configuration for integration with OneFuzz, and includes seed corpora for effective fuzzing coverage.

Fuzzing infrastructure:

  • Added a new project AIDevGallery.Fuzz to the solution, including its project file and solution integration, to support fuzz testing of critical components.
  • Created FuzzTargets.cs with fuzz targets for following scenarios including checks for path traversal and malformed input handling:
    • The custom URI protocol handler,
    • HuggingFace URL parser,
    • GitHub URL parser,

Fuzzing configuration and automation:

  • Added OneFuzzConfig.json to configure OneFuzz jobs for each fuzz target, specifying job dependencies and notification settings.

Seed corpora for fuzzing:

  • Added a variety of seed corpus files under SeedCorpus/ for URIs, HuggingFace URLs, and GitHub URLs to ensure broad input coverage for fuzzing.

These changes enable automated fuzz testing for key parsing logic, helping to proactively identify and mitigate security vulnerabilities and robustness issues in the application.

Copilot AI review requested due to automatic review settings February 9, 2026 03:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated fuzzing project to AI Dev Gallery to harden URI/deeplink and model URL parsing code paths using libFuzzer/.NET + OneFuzz configuration and seed corpora.

Changes:

  • Added new AIDevGallery.Fuzz project to the solution for fuzzing targets.
  • Introduced fuzz targets for the app’s custom URI protocol handler and HuggingFace/GitHub URL parsing utilities.
  • Added OneFuzzConfig.json plus seed corpora files for URI/URL inputs.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
AIDevGallery.sln Adds the new fuzzing project to the solution and build configurations.
AIDevGallery.Fuzz/AIDevGallery.Fuzz.csproj New fuzzing project referencing AIDevGallery.Utils and copying OneFuzz config to output.
AIDevGallery.Fuzz/FuzzTargets.cs Implements fuzz targets for deeplink URI parsing + HuggingFace/GitHub URL parsing.
AIDevGallery.Fuzz/OneFuzzConfig.json Defines OneFuzz jobs for each fuzz target and their dependencies.
AIDevGallery.Fuzz/SeedCorpus/uri/scenarios_valid_id Seed input for scenario deep link parsing.
AIDevGallery.Fuzz/SeedCorpus/uri/models_single_id Seed input for model deep link parsing.
AIDevGallery.Fuzz/SeedCorpus/uri/apis_valid_id Seed input for API deep link parsing.
AIDevGallery.Fuzz/SeedCorpus/uri/addmodel_with_scenario Seed input for addmodel deeplink with GUID scenario.
AIDevGallery.Fuzz/SeedCorpus/uri/addmodel_simple_path Seed input for addmodel deeplink with simple path + scenario.
AIDevGallery.Fuzz/SeedCorpus/huggingface/tree_with_ref Seed HuggingFace URL (tree, ref only).
AIDevGallery.Fuzz/SeedCorpus/huggingface/tree_with_path Seed HuggingFace URL (tree, ref + nested path).
AIDevGallery.Fuzz/SeedCorpus/huggingface/resolve_file Seed HuggingFace URL (resolve file).
AIDevGallery.Fuzz/SeedCorpus/huggingface/repo_root_only Seed HuggingFace URL (repo root).
AIDevGallery.Fuzz/SeedCorpus/huggingface/model_id_only Seed HuggingFace model id (no scheme).
AIDevGallery.Fuzz/SeedCorpus/huggingface/blob_file Seed HuggingFace URL (blob file).
AIDevGallery.Fuzz/SeedCorpus/github/tree_with_ref Seed GitHub URL (tree, ref only).
AIDevGallery.Fuzz/SeedCorpus/github/tree_with_path Seed GitHub URL (tree, ref + nested path).
AIDevGallery.Fuzz/SeedCorpus/github/repo_root_only Seed GitHub URL (repo root).
AIDevGallery.Fuzz/SeedCorpus/github/blob_file Seed GitHub URL (blob file).

Comment on lines 99 to 112
// Critical: Test local path generation for path traversal
var localPath = hfUrl.GetLocalPath(@"C:\ModelCache");

// Verify no path traversal occurred
if (!localPath.StartsWith(@"C:\ModelCache", StringComparison.OrdinalIgnoreCase))
{
throw new InvalidOperationException($"Path traversal detected: {localPath}");
}

// Check for path components that shouldn't be in a safe path
if (localPath.Contains(".."))
{
throw new InvalidOperationException($"Path contains '..': {localPath}");
}
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The traversal assertion is currently based on StartsWith("C:\ModelCache") and localPath.Contains(".."). This can both miss traversal after normalization and create false positives when ".." appears inside a normal segment (e.g., "repo..name"). Prefer comparing Path.GetFullPath(localPath) to a normalized cache root (including a trailing separator) and/or using Path.GetRelativePath to ensure the result doesn’t escape the cache root.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 63 to 69
else if (host.Equals("scenarios", StringComparison.OrdinalIgnoreCase))
{
// Test scenario ID extraction
if (pathComponents.Length > 0)
{
_ = pathComponents[0];
}
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 'if' statements can be combined.

Suggested change
else if (host.Equals("scenarios", StringComparison.OrdinalIgnoreCase))
{
// Test scenario ID extraction
if (pathComponents.Length > 0)
{
_ = pathComponents[0];
}
else if (host.Equals("scenarios", StringComparison.OrdinalIgnoreCase) &&
pathComponents.Length > 0)
{
// Test scenario ID extraction
_ = pathComponents[0];

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@haoliuu haoliuu force-pushed the haoliu/fuzz-testing branch from 010fcac to 2ce4a55 Compare February 9, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant