Files
semantic-kernel/python/semantic_kernel/connectors
Roger Barreto 6ba60965bd Python: Reject encoded dot-segment paths in OpenAPI plugin (.NET and Python) (#14086)
## Motivation and Context

Closes #14085.

The .NET and Python OpenAPI plugins select operations using the raw
OpenAPI path, but build the runtime request URL from a canonicalized
path. Encoded dot-segments such as `/resources/%2e%2e/admin` pass an
`OperationSelectionPredicate` path check, yet `System.Uri` (.NET) and
`urljoin` (Python) collapse them to a different route at request time.
The selected path and the actual request target can therefore diverge.

## Description

- **.NET** (`RestApiOperation.ValidatePathSegments`): decodes each path
segment until stable (handling double encoding like `%252e` and encoded
separators `%2f`/`%5c`) before rejecting canonical `.` or `..` segments.
- **Python** (`RestApiOperation.build_path`): adds equivalent
decode-then-reject validation before the URL is built.

Regression tests on both stacks cover literal and encoded dot-segments,
mixed case, encoded slashes, and double encoding, plus negative tests
confirming legitimate encoded characters still work.

Test results:
- .NET: 482/482 `Functions.UnitTests` OpenApi tests pass.
- Python: 109/109 `openapi_plugin` unit tests pass.

## Contribution Checklist

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the SK Contribution Guidelines
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
2026-06-16 17:40:54 +00:00
..
2024-11-19 16:36:01 +00:00
2026-05-14 00:46:19 +00:00