Angular SSR route-policy confusion can expose client-only data under public cache headers
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- angular, typescript
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện sự không khớp với hai yêu cầu curl và cấu hình ServerRoute tối thiểu. Theo dõi cách Angular SSR chọn renderMode và response headers cho /profile; và cách Angular Router render /profile; và /profile//public. Được xem là hoàn tất khi body được render, renderMode và các cache headers luôn tương ứng với cùng một route, không để lộ giá trị nào bắt nguồn từ request cho client-only route.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Angular SSR can select server-route metadata from one route while Angular Router renders a different route when the request URL contains certain ambiguous path forms.
Example:
/profile;
/profile//public
In both cases, a route configured as RenderMode.Client can be unexpectedly rendered on the server while inheriting public cache headers from another ServerRoute.
Minimal Reproduction
Minimal configuration
import { RenderMode, ServerRoute } from '@angular/ssr';
export const serverRoutes: ServerRoute[] = [
{
path: 'profile',
renderMode: RenderMode.Client,
headers: {
'Cache-Control': 'private, no-store',
},
},
{
path: 'profile/public',
renderMode: RenderMode.Server,
headers: {
'Cache-Control': 'public, max-age=300',
},
},
{
path: '**',
renderMode: RenderMode.Server,
headers: {
'Cache-Control': 'public, max-age=300',
},
},
];
The /profile component reads a benign request-derived marker through the SSR REQUEST token.
Steps to reproduce
Request the normal client-only route:
curl -i \
-H 'Cookie: session=PRIVATE_VALUE' \
http://localhost:4000/profile
The initial HTML does not contain the request-derived value.
Request either crafted path:
curl -i \
-H 'Cookie: session=PRIVATE_VALUE' \
'http://localhost:4000/profile;'
curl -i \
-H 'Cookie: session=PRIVATE_VALUE' \
http://localhost:4000/profile//public
Actual behavior
The crafted requests can:
- render the
/profilecomponent on the server; - expose request-derived data in the initial HTML;
- apply
Cache-Control: publicmetadata belonging to another server route.
Expected behavior
The route used to select renderMode, status, and response headers must always correspond to the route whose body is rendered.
A route configured as RenderMode.Client should not be server-rendered through an alternative URL representation.
Your Environment
Angular 22.X
Anything else relevant?
This was previously reported at https://issuetracker.google.com/u/1/issues/518988455
- Ngôn ngữ chính
- TypeScript
- Star
- 27k
- Fork
- 11.8k
- Merge trung bình
- 16 giờ 21 phút
- Pull request đã merge (30 ngày)
- 170
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của angular/angular-cli
-
area: @angular/build gemini-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
angular/angular-cli#34129 ·
-
Support aube as package manager Đang mởarea: @angular/cli gemini-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
angular/angular-cli#34057 ·
-
Can't use an array of hostnames in --allowedHosts cli parameter in @angular/build:dev-server Đang mởarea: @angular/build gemini-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
angular/angular-cli#33055 · 1 bình luận · 3 reaction ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 1 người được giao ·