33

RFC 3986 URI: Generic Syntax仕様には、セミコロンが予約済み (サブデリム) 文字としてリストされています。

reserved    = gen-delims / sub-delims

gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"

sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
              / "*" / "+" / "," / ";" / "="

「;」の予約された目的は何ですか URI のセミコロンの? さらに言えば、他のサブデリムの目的は何ですか (「&」、「+」、および「=」の目的しか認識していません)。

4

6 に答える 6

40

There is an explanation at the end of section 3.3.

Aside from dot-segments in hierarchical paths, a path segment is considered opaque by the generic syntax. URI producing applications often use the reserved characters allowed in a segment to delimit scheme-specific or dereference-handler-specific subcomponents. For example, the semicolon (";") and equals ("=") reserved characters are often used to delimit parameters and parameter values applicable to that segment. The comma (",") reserved character is often used forsimilar purposes. For example, one URI producer might use a segment uch as "name;v=1.1" to indicate a reference to version 1.1 of "name", whereas another might use a segment such as "name,1.1" to indicate the same. Parameter types may be defined by scheme-specific semantics, but in most cases the syntax of a parameter is specific to the implementation of the URI's dereferencing algorithm.

In other words, it is reserved so that people who want a delimited list of something in the URL can safely use ; as a delimiter even if the parts contain ;, as long as the contents are percent-encoded. In other words, you can do this:

foo;bar;baz%3bqux

and interpret it as three parts: foo, bar, baz;qux. If semicolon were not a reserved character, the ; and %3bwould be equivalent, so the URI would be incorrectly interpreted as four parts: foo, bar, baz, qux.

于 2010-01-29T17:41:40.170 に答える
9

古いバージョンの仕様に戻ると、意図はより明確になります。

  path_segments = segment *( "/" segment )
  segment       = *pchar *( ";" param ) 

各パス セグメントには、セミコロン「;」で示される一連のパラメータを含めることができます。キャラクター。

FTP URIに起源があると思います。

于 2010-01-29T17:50:10.363 に答える
5

Section 3.3 covers this - it's an opaque delimiter a URI-producing application can use if convenient:

Aside from dot-segments in hierarchical paths, a path segment is considered opaque by the generic syntax. URI producing applications often use the reserved characters allowed in a segment to delimit scheme-specific or dereference-handler-specific subcomponents. For example, the semicolon (";") and equals ("=") reserved characters are often used to delimit parameters and parameter values applicable to that segment. The comma (",") reserved character is often used for similar purposes. For example, one URI producer might use a segment such as "name;v=1.1" to indicate a reference to version 1.1 of "name", whereas another might use a segment such as "name,1.1" to indicate the same. Parameter types may be defined by scheme-specific semantics, but in most cases the syntax of a parameter is specific to the implementation of the URI's dereferencing algorithm.

于 2010-01-29T17:40:56.473 に答える
4

現在の使用法には、興味深い慣例がいくつかあります。これらは、いつセミコロンまたはコンマを使用するかを示しています。本「RESTful Webサービス」から:

同じ階層レベルにある複数のデータを区切るには、句読点を使用します。項目の順序が重要な場合はカンマを使用し、順序が重要でない場合はセミコロンを使用します。

于 2013-07-04T18:56:10.220 に答える
3

2014 年以降、パス セグメントはReflected File Download 攻撃に寄与することが知られています。送信したものを反映する脆弱な API があるとします。

https://google.com/s?q=rfd%22||calc||

{"results":["q", "rfd\"||calc||","I love rfd"]}

現在、これは JSON であるためブラウザーでは無害であるため、レンダリングされることはありませんが、ブラウザーは応答をファイルとしてダウンロードすることを提案します。ここで、(攻撃者にとって) 役立つパス セグメントを次に示します。

https://google.com/s;/setup.bat;?q=rfd%22||calc||

セミコロン ( ;/setup.bat;)の間のすべては Web サービスに送信されませんが、代わりにブラウザーはそれをファイル名として解釈し、API 応答を保存します。

これで、 というファイルsetup.batがダウンロードされ、インターネットからダウンロードしたファイルを実行する危険性について尋ねずに実行されます ("setup"名前に単語が含まれているため)。内容は Windows バッチ ファイルとして解釈され、calc.exeコマンドが実行されます。

防止:

  • API の入力をサニタイズします (この場合、英数字のみを許可する必要があります)。逃げるだけでは不十分
  • Content-Disposition: attachment; filename="whatever.txt"レンダリングされない API を追加します。filenameGoogle には、実際に攻撃を容易にする部分が欠けていた
  • X-Content-Type-Options: nosniffAPI 応答にヘッダーを追加する
于 2014-10-21T14:29:53.663 に答える