Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

No problem is insoluble. -- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4


devel / comp.lang.lisp / Rationale for certain CL-WHO behavior.

SubjectAuthor
* Rationale for certain CL-WHO behavior.Kaz Kylheku
`* Re: Rationale for certain CL-WHO behavior.Kaz Kylheku
 `* Re: Rationale for certain CL-WHO behavior.Kaz Kylheku
  `* Re: Rationale for certain CL-WHO behavior.Spiros Bousbouras
   `* Re: Rationale for certain CL-WHO behavior.Kaz Kylheku
    `* Re: Rationale for certain CL-WHO behavior.Spiros Bousbouras
     `- Re: Rationale for certain CL-WHO behavior.Benjamin Esham

1
Rationale for certain CL-WHO behavior.

<20230529120045.950@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17408&group=comp.lang.lisp#17408

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Rationale for certain CL-WHO behavior.
Date: Mon, 29 May 2023 19:30:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <20230529120045.950@kylheku.com>
Injection-Date: Mon, 29 May 2023 19:30:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c9a7b14fa665d867d13efc298dfa8530";
logging-data="1692451"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fZg+BgQa2hwwvcZGa5kGaX2XozhnvPPY="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:aRbPX93p5mJogvZKGfj790szIOQ=
 by: Kaz Kylheku - Mon, 29 May 2023 19:30 UTC

In CL-WHO, expressions which give attribute values are evaluated. If
they produce text it is HTML-escaped and turns into an attribute.

(:table :border (+ 1 2)) -> <table border='3'></table>

But, expressions elsewhere in the template are only evaluated;
their values do not become HTML output.

(:table :border (+ 1 2)
(identity "abc")) -> <table border='3'></table>

Except for constant strings:

(:table :border (+ 1 2)
"abc") -> <table border='3'>abc</table>

You have to make explicit use of certain local macros like str:

(:table :border (+ 1 2)
(str (identity "abc"))) -> <table border='3'>abc</table>

It seems inconsistent/inconvenient. Does anyone know why Weitz
designed and kept it that way?

Is it too much of a footgun to interpolate all the expressions
into the output?

Or was it more important to be able to write in side-effects
with minimal fuss?

I'm leaning toward wanting it to just interpolate values
by default and having some operator for indicating that
forms are there for effect only:

(:div :class "greeting"
"Hello, " user ;; emitted
;; effect only:
(do (debug "emitted greeting for user ~a" user)))

->

Here, the HTML macro recognizes (do ...) and converts
it to (progn ...), but any other form becomes (str form),
and so outputs.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Rationale for certain CL-WHO behavior.

<20230529142520.337@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17409&group=comp.lang.lisp#17409

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Rationale for certain CL-WHO behavior.
Date: Mon, 29 May 2023 21:35:21 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <20230529142520.337@kylheku.com>
References: <20230529120045.950@kylheku.com>
Injection-Date: Mon, 29 May 2023 21:35:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c9a7b14fa665d867d13efc298dfa8530";
logging-data="1750656"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+RT2FaRACBrw2+hklRAKsuB17cLX33Gnk="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:yLWgh2PhM/NDRPa4VxJurxHUwOc=
 by: Kaz Kylheku - Mon, 29 May 2023 21:35 UTC

On 2023-05-29, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
> I'm leaning toward wanting it to just interpolate values
> by default and having some operator for indicating that
> forms are there for effect only:
>
> (:div :class "greeting"
> "Hello, " user ;; emitted
> ;; effect only:
> (do (debug "emitted greeting for user ~a" user)))

But, the thing is, most of the CL-WHO examples do some kind of loop:

(:table :cellpadding 0 :border 4
(loop for r in rows
do (htm (:tr ...))))

Here, the loop is purely effectful; its return value isn't being
considered for output. If you have a lot of code like this, you're
looking at explicitly annotating all those loops as being side-effect
only. If you forget, you get extra bits of garbage in the HTML output
you might not even notice.

If it sucked this way, people would ahve changed it years ago,
or added some mode flag.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Rationale for certain CL-WHO behavior.

<20230529152823.979@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17410&group=comp.lang.lisp#17410

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Rationale for certain CL-WHO behavior.
Date: Mon, 29 May 2023 22:39:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <20230529152823.979@kylheku.com>
References: <20230529120045.950@kylheku.com> <20230529142520.337@kylheku.com>
Injection-Date: Mon, 29 May 2023 22:39:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7e64d862daf8fbe0fc97f4eab5b1e0a1";
logging-data="1779099"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LGdK+tZ3U06yR5Bv0uGTYib3z9tsfPeY="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:I7b1OEDYIKmCe886gJbfpKLFpf4=
 by: Kaz Kylheku - Mon, 29 May 2023 22:39 UTC

On 2023-05-29, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
> On 2023-05-29, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>> I'm leaning toward wanting it to just interpolate values
>> by default and having some operator for indicating that
>> forms are there for effect only:
>>
>> (:div :class "greeting"
>> "Hello, " user ;; emitted
>> ;; effect only:
>> (do (debug "emitted greeting for user ~a" user)))
>
> But, the thing is, most of the CL-WHO examples do some kind of loop:
>
> (:table :cellpadding 0 :border 4
> (loop for r in rows
> do (htm (:tr ...))))
>
> Here, the loop is purely effectful; its return value isn't being
> considered for output. If you have a lot of code like this, you're
> looking at explicitly annotating all those loops as being side-effect
> only. If you forget, you get extra bits of garbage in the HTML output
> you might not even notice.
>
> If it sucked this way, people would ahve changed it years ago,
> or added some mode flag.

On the other hand, that handling of attributes is vulnerable to injection; it's
not doing any escaping!

[1]> (cl-who:with-html-output-to-string (out)
(:table :cellpadding "0'>hahaha</table>" "what???"))
"<table cellpadding='0'>hahaha</table>'>what???</table>"

Simply astonishing. If you happen to have any sensitive of data going into
attributes that a user could manipulate, you have to remember to your own
escaping, or you've enabled an injection attack.

The local macro (fmt ...) has the same problem; no escaping.

If you want escaping you use (esc ...), but that doesn't have any
format cruft you might want.

If you want formatting with (fmt ...), that doesn't escape; you have
a possible injection attack if you interpolate some string controlled
by a remote user.

Then there is the local macro (str ...) which combines the lack of
functionality of esc, with the insecurity of (fmt ...).

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Rationale for certain CL-WHO behavior.

<O=i1yQtfseXpS0qG6@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17411&group=comp.lang.lisp#17411

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: Rationale for certain CL-WHO behavior.
Date: Tue, 30 May 2023 11:08:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <O=i1yQtfseXpS0qG6@bongo-ra.co>
References: <20230529120045.950@kylheku.com> <20230529142520.337@kylheku.com> <20230529152823.979@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 30 May 2023 11:08:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0aef10006887de4719358fe2c312b88f";
logging-data="2079804"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1963lFbyb2vyDifZcSbob8Q"
Cancel-Lock: sha1:nanC7AOz+RM3yxFc12iw8DvxZi8=
X-Server-Commands: nowebcancel
X-Organisation: Weyland-Yutani
In-Reply-To: <20230529152823.979@kylheku.com>
 by: Spiros Bousbouras - Tue, 30 May 2023 11:08 UTC

On Mon, 29 May 2023 22:39:05 -0000 (UTC)
Kaz Kylheku <864-117-4973@kylheku.com> wrote:
> On 2023-05-29, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
> > If it sucked this way, people would ahve changed it years ago,
> > or added some mode flag.

Perhaps not many people use the library.

> On the other hand, that handling of attributes is vulnerable to injection; it's
> not doing any escaping!
>
> [1]> (cl-who:with-html-output-to-string (out)
> (:table :cellpadding "0'>hahaha</table>" "what???"))
> "<table cellpadding='0'>hahaha</table>'>what???</table>"
>
> Simply astonishing. If you happen to have any sensitive of data going into
> attributes that a user could manipulate, you have to remember to your own
> escaping, or you've enabled an injection attack.

I've never used the library so I don't know in which situations you'd want
to use it. Can you describe a realistic scenario where the possibilities
you mention would be relevant and what you would consider a good behaviour
in such situations ?

Re: Rationale for certain CL-WHO behavior.

<20230530065050.381@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17412&group=comp.lang.lisp#17412

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Rationale for certain CL-WHO behavior.
Date: Tue, 30 May 2023 14:20:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <20230530065050.381@kylheku.com>
References: <20230529120045.950@kylheku.com>
<20230529142520.337@kylheku.com> <20230529152823.979@kylheku.com>
<O=i1yQtfseXpS0qG6@bongo-ra.co>
Injection-Date: Tue, 30 May 2023 14:20:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7e64d862daf8fbe0fc97f4eab5b1e0a1";
logging-data="2125381"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ekKQHBUp0PLw3sb2e3BSPlw4v2EINO6Y="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:/K0+13DsW1yPAh3wGlReGeIGR8g=
 by: Kaz Kylheku - Tue, 30 May 2023 14:20 UTC

On 2023-05-30, Spiros Bousbouras <spibou@gmail.com> wrote:
> On Mon, 29 May 2023 22:39:05 -0000 (UTC)
> Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>> On 2023-05-29, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>> > If it sucked this way, people would ahve changed it years ago,
>> > or added some mode flag.
>
> Perhaps not many people use the library.
>
>> On the other hand, that handling of attributes is vulnerable to injection; it's
>> not doing any escaping!
>>
>> [1]> (cl-who:with-html-output-to-string (out)
>> (:table :cellpadding "0'>hahaha</table>" "what???"))
>> "<table cellpadding='0'>hahaha</table>'>what???</table>"
>>
>> Simply astonishing. If you happen to have any sensitive of data going into
>> attributes that a user could manipulate, you have to remember to your own
>> escaping, or you've enabled an injection attack.
>
> I've never used the library so I don't know in which situations you'd want
> to use it.

Generating HTML; e.g. in the dynamic pages of a web application.

> Can you describe a realistic scenario where the possibilities
> you mention would be relevant and what you would consider a good behaviour
> in such situations ?

Say we are coding a forum site and we have a page where user
profiles can be viewed. Users have websites:

... "Website:" (:a :href user-website-url ...) ...

The user-website-url comes from the user's profile; it is user-editable.

If user-website-url is not subject to HTML escaping, we have a security
issue: a user can put malicious HTML fragments into their website
string, which become part of the profile page, so that the page then
perpetrates an attack on someone who merely loads it.

The default interpolation behavior in HTML generation utilities should
be secure. When a HTML utility is used in its most succinct, convenient
and canonical way, as recommended by its documentation and examples, its
behavior should be secure.

Opting out of security should be the inconvenient choice requiring some
extra code, not opting in.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Rationale for certain CL-WHO behavior.

<zZr9+jeEZXZNZTtH2@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17413&group=comp.lang.lisp#17413

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!paganini.bofh.team!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: Rationale for certain CL-WHO behavior.
Date: Wed, 31 May 2023 15:03:19 -0000 (UTC)
Organization: To protect and to server
Message-ID: <zZr9+jeEZXZNZTtH2@bongo-ra.co>
References: <20230529120045.950@kylheku.com> <20230529142520.337@kylheku.com> <20230529152823.979@kylheku.com>
<O=i1yQtfseXpS0qG6@bongo-ra.co> <20230530065050.381@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 31 May 2023 15:03:19 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="3942324"; posting-host="9H7U5kayiTdk7VIdYU44Rw.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
Cancel-Lock: sha256:cNKhR2dBM83L5tVejCn1nEEUpgFwZJPaZPhN0kqg7Bw=
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
X-Notice: Filtered by postfilter v. 0.9.3
 by: Spiros Bousbouras - Wed, 31 May 2023 15:03 UTC

On Tue, 30 May 2023 14:20:15 -0000 (UTC)
Kaz Kylheku <864-117-4973@kylheku.com> wrote:
> On 2023-05-30, Spiros Bousbouras <spibou@gmail.com> wrote:
> > I've never used the library so I don't know in which situations you'd want
> > to use it.
>
> Generating HTML; e.g. in the dynamic pages of a web application.
>
> > Can you describe a realistic scenario where the possibilities
> > you mention would be relevant and what you would consider a good behaviour
> > in such situations ?
>
> Say we are coding a forum site and we have a page where user
> profiles can be viewed. Users have websites:
>
> ... "Website:" (:a :href user-website-url ...) ...
>
> The user-website-url comes from the user's profile; it is user-editable.
>
> If user-website-url is not subject to HTML escaping, we have a security
> issue: a user can put malicious HTML fragments into their website
> string, which become part of the profile page, so that the page then
> perpetrates an attack on someone who merely loads it.

The user will modify their profile by filling fields on some form ,
right ? How do you go from that to evaluating
(:a :href user-website-url ...) ? Wouldn't you sanitise what the user
entered at the time they entered it ?

Re: Rationale for certain CL-WHO behavior.

<rvkxol.ncaqot@bdesham.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17414&group=comp.lang.lisp#17414

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: usenet@esham.io (Benjamin Esham)
Newsgroups: comp.lang.lisp
Subject: Re: Rationale for certain CL-WHO behavior.
Date: Thu, 01 Jun 2023 11:17:48 -0400
Organization: United Federation of Planets
Lines: 52
Message-ID: <rvkxol.ncaqot@bdesham.net>
References: <20230529120045.950@kylheku.com> <20230529142520.337@kylheku.com>
<20230529152823.979@kylheku.com> <O=i1yQtfseXpS0qG6@bongo-ra.co>
<20230530065050.381@kylheku.com> <zZr9+jeEZXZNZTtH2@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="ebad4d9cdf4b87e7a09f8dabb1df19bc";
logging-data="2975651"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cjd3OgHq+H3ZNAIFLn7trZPAxnZO3UpbMz/CihuU7Bw=="
User-Agent: Gnus/5.13 (macOS)
Cancel-Lock: sha1:3ilqA/4S+1BrTVMCrwsNnUBp6RY=
sha1:qumv9fYwTTkuxmkPzBrwXbSxuqY=
 by: Benjamin Esham - Thu, 1 Jun 2023 15:17 UTC

Spiros Bousbouras wrote:

> On Tue, 30 May 2023 14:20:15 -0000 (UTC)
> Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>
>> On 2023-05-30, Spiros Bousbouras <spibou@gmail.com> wrote:
>>
>>> Can you describe a realistic scenario where the possibilities you
>>> mention would be relevant and what you would consider a good behaviour
>>> in such situations ?
>>
>> Say we are coding a forum site and we have a page where user
>> profiles can be viewed. Users have websites:
>>
>> ... "Website:" (:a :href user-website-url ...) ...
>>
>> The user-website-url comes from the user's profile; it is user-editable.
>>
>> If user-website-url is not subject to HTML escaping, we have a security
>> issue: a user can put malicious HTML fragments into their website
>> string, which become part of the profile page, so that the page then
>> perpetrates an attack on someone who merely loads it.
>
> The user will modify their profile by filling fields on some form ,
> right ? How do you go from that to evaluating
> (:a :href user-website-url ...) ? Wouldn't you sanitise what the user
> entered at the time they entered it ?

In my experience it's much more common to do sanitizing on output, not on
input. For one thing, different output formats require different forms of
sanitization. If you're producing HTML, you probably want to change every
"&" to "&amp;". If you're producing JSON you don't want to do that, but
there are other forms of escaping you need to do. Keeping the data in its
original form in your data store means that you can defer the decision about
which form to use until you actually know what output format you're
targeting.

Another consideration is that new forms of injection are being created and
discovered all the time. If you sanitize the user's input as soon as they
enter it, how are you going to handle the possibility that it contains
malicious code that you weren't able to identify at the time, but learn
about later?

You could sanitize on the way in *and* on the way out, but you'd better hope
that your processing is idempotent. I guess you could periodically
re-sanitize your entire database, but that has the same problem and could be
quite resource intensive. Or--as above--you could defer the decision until
you're actually ready to do something with the user's input, at which point
you have the most up-to-date information about which entries might be
problematic.

Benjamin

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor