Kaydet (Commit) 0c0565dd authored tarafından Barry Warsaw's avatar Barry Warsaw

Toughen up the security warnings a bit.

üst 5e17d207
...@@ -42,11 +42,10 @@ This class derives from \class{BaseCookie} and overrides ...@@ -42,11 +42,10 @@ This class derives from \class{BaseCookie} and overrides
\method{value_decode()} and \method{value_encode()} to be the \method{value_decode()} and \method{value_encode()} to be the
\function{pickle.loads()} and \function{pickle.dumps()}. \function{pickle.loads()} and \function{pickle.dumps()}.
Do not use this class. Reading pickled values from a cookie is a \strong{Do not use this class!} Reading pickled values from untrusted
security hole, as arbitrary client-code can be run on cookie data is a huge security hole, as pickle strings can be crafted
\function{pickle.loads()}. It is supported for backwards to cause arbitrary code to execute on your server. It is supported
compatibility. for backwards compatibility only, and may eventually go away.
\end{classdesc} \end{classdesc}
\begin{classdesc}{SmartCookie}{\optional{input}} \begin{classdesc}{SmartCookie}{\optional{input}}
...@@ -56,9 +55,17 @@ valid pickle, and otherwise the value itself. It overrides ...@@ -56,9 +55,17 @@ valid pickle, and otherwise the value itself. It overrides
\method{value_encode()} to be \function{pickle.dumps()} unless it is a \method{value_encode()} to be \function{pickle.dumps()} unless it is a
string, in which case it returns the value itself. string, in which case it returns the value itself.
The same security warning from \class{SerialCookie} applies here. \strong{Note:} The same security warning from \class{SerialCookie}
applies here.
\end{classdesc} \end{classdesc}
A further security note is warranted. For backwards compatibility,
the \module{Cookie} module exports a class named \class{Cookie} which
is just an alias for \class{SmartCookie}. This is probably a mistake
and will likely be removed in a future version. You should not use
the \class{Cookie} class in your applications, for the same reason why
you should not use the \class{SerialCookie} class.
\begin{seealso} \begin{seealso}
\seerfc{2109}{HTTP State Management Mechanism}{This is the state \seerfc{2109}{HTTP State Management Mechanism}{This is the state
...@@ -181,8 +188,6 @@ The following example demonstrates how to use the \module{Cookie} module. ...@@ -181,8 +188,6 @@ The following example demonstrates how to use the \module{Cookie} module.
>>> C = Cookie.SimpleCookie() >>> C = Cookie.SimpleCookie()
>>> C = Cookie.SerialCookie() >>> C = Cookie.SerialCookie()
>>> C = Cookie.SmartCookie() >>> C = Cookie.SmartCookie()
>>> C = Cookie.Cookie() # backwards-compatible alias for SmartCookie
>>> C = Cookie.SmartCookie()
>>> C["fig"] = "newton" >>> C["fig"] = "newton"
>>> C["sugar"] = "wafer" >>> C["sugar"] = "wafer"
>>> print C # generate HTTP headers >>> print C # generate HTTP headers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment