`cupsdWritePrintcap`: `printer-info` written to printcap unescaped (control characters not neutralized)
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start in cupsdWritePrintcap() in scheduler/printers.c, where p->info is written raw in the BSD branch (around lines 3187 and 3195) and the Solaris branch (around lines 3291-3297). The validator behaviour is in ippValidateAttribute in cups/ipp.c. Build the reproduction program from the issue to confirm a raw LF is accepted for printer-info. Done means a printer-info containing a newline no longer produces a second printcap entry on either branch. Choosing between the three suggested fixes needs maintainer agreement first.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
cupsdWritePrintcap() (scheduler/printers.c) writes p->info directly into the printcap
file without escaping control characters. Because printer-info is an IPP text-typed value,
ippValidateAttribute accepts a raw \n/\r/\t in it, so a printer-info containing a
newline passes validation and reaches the printcap writer unchanged. One embedded newline ends
the current printcap line and starts a second, fully attacker-shaped entry.
This is a hardening gap analogous to cupsFilePutConf() (cups/file.c:1334), which already
escapes #, \, \n, \r when writing the same Info value to printers.conf. The printcap
writer has no equivalent neutralization.
Root cause
1. The text validator exempts newlines. cups/ipp.c, ippValidateAttribute, text branch:
else if (_cups_iscntrl(*ptr) && *ptr != '\n' && *ptr != '\r' && *ptr != '\t')
{
/* reject */
}
\n/\r/\t are explicitly allowed for IPP_TAG_TEXT. The name branch rejects all control
characters, which is why the earlier printer-name fix did not cover printer-info (it goes
through the text branch).
2. Both printcap writers emit p->info raw. scheduler/printers.c, cupsdWritePrintcap.
BSD branch (line 3195; the default-printer line at 3187 has the same shape):
cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", p->name, p->info, ServerName, p->name);
Solaris branch (lines 3291-3297) writes description=%s from the same p->info, where a newline
ends the description= field and whatever follows becomes a new entry:
cupsFilePrintf(fp, "%s:\\\n\t:bsdaddr=%s,%s:\\\n\t:description=%s:\n",
p->name, ServerName, p->name, p->info ? p->info : "");
Fixing only the BSD line leaves the Solaris path open.
Reproduction (validator differential)
val.c — shows a raw LF accepted in printer-info (text) and rejected in printer-name (name):
#include "cups/ipp.h"
#include "cups/cups.h"
#include <stdio.h>
#include <string.h>
int main(void){
struct { const char *tag; const char *name; const char *val; } cases[] = {
{"TEXT","printer-info","Office\nFAKE|spoof:rm=host:rp=q:"},
{"NAME","printer-name","q\nFAKE"},
{"TEXT","printer-info","Clean Office Printer"},
};
for (int i=0;i<3;i++){
ipp_t *r = ippNew();
ipp_tag_t vt = strcmp(cases[i].tag,"NAME")==0 ? IPP_TAG_NAME : IPP_TAG_TEXT;
ippAddString(r, IPP_TAG_PRINTER, vt, cases[i].name, NULL, cases[i].val);
int ok = ippValidateAttributes(r);
printf("%-5s %-16s raw-LF=%d -> %s\n", cases[i].tag, cases[i].name,
strchr(cases[i].val,'\n')?1:0, ok?"ACCEPTED":"rejected");
ippDelete(r);
}
return 0;
}
Output (built against the tree with clang -I. -Icups -D_CUPS_SOURCE):
TEXT printer-info raw-LF=1 -> ACCEPTED
NAME printer-name raw-LF=1 -> rejected
TEXT printer-info raw-LF=0 -> ACCEPTED
With printer-info = "Office Printer\nINJECTED|desc:rm=host:rp=q:" stored on a queue, a printcap
rewrite produces two lines where only one was intended — the second is attacker-shaped:
EvilQueue|Office Printer
INJECTED|desc:rm=host:rp=q::rm=<server>:rp=EvilQueue:
printer-info reaches p->info unchanged via create_local_printer (scheduler/ipp.c:5985) and
add_printer (CUPS-Add-Modify-Printer), both of which mark the printcap dirty.
Suggested fix
Any one of these closes it; the first is the most contained:
- Escape control characters in both printcap writers in
cupsdWritePrintcap(BSD
printers.c:3187/3195, Solaris3291-3297), the same waycupsFilePutConfdoes for
printers.conf. - Strip
\n/\rfromprinter-info(andprinter-location) when it is stored. - Have the
textvalidator reject control characters for values that end up in line-oriented
files.
- Ngôn ngữ chính
- C
- Star
- 1.8k
- Fork
- 367
- Merge trung bình
- 1 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc 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 OpenPrinting/cups
-
Send-Document has no job-state check, resurrects canceled jobs and re-prints processing jobsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
OpenPrinting/cups#1833 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
OAuth (bearer) quota check denies every user when the allowed-user list is emptyCó thể đã có người làm @RonitMehta08 đã nhận 9 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
OpenPrinting/cups#1795 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
cupsdGetPrivateAttrs: @ACL never grants access, and @OWNER is looked up as an operating-system group for non-ownersCó thể đã có người làm @user-Param đã nhận 16 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
OpenPrinting/cups#1796 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
OAuth/OIDC token-validation gaps: nonce not enforced when absent, at_hash alg, inbound bearer not signature/aud/exp-validated + unverified email used for authzCó thể làm lại được @michaelrsweet đã nhận 154 ngày trước và không có pull request nào đang mở. Đang mởinvestigating
OpenPrinting/cups#1609 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
OpenPrinting/cups#1572 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của OpenPrinting/cups
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
compiler-explorer/compiler-explorer#9710 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
libsndfile/libsndfile#1238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
DaveGamble/cJSON#1143 ·