XSF Discussion - 2022-12-03


  1. Guus

    Does XMPP use namespaces on the stream other than 'http://etherx.jabber.org/streams' and the namespace that defines the stanzas ('jabber:client', 'jabber:server' etc)? I can think of only one, for dialback. Are there others?

  2. flow

    Guus, define on the stream? All Nonzas have their own namespace

  3. Guus

    I guess that in specialized scenarios, other (private/proprietary?) namespaces could possibly be added? I've never seen that - at least not with such namespaces being defined on the stream element.

  4. Guus

    defined as an attribute on the <stream> element.

  5. flow

    ahh, well in theory you could pre-define a ton of namespaces there

  6. Zash

    You're talking about namespace prefix declarations on the root stream?

  7. flow

    and use this as optimization when sending an element of such a namespace

  8. Guus

    flow/zash; yes, that's what I mean.

  9. flow

    It's one of those "XML allows it, XMPP does not explicitly forbid it, but implementations usually do not do it" things

  10. flow

    for example like namespaced attributes

  11. Guus

    That's what I was wondering. I've never _seen_ it - but does it happen in the wild. Dialback is one, I think, but is there more?

  12. flow

    I can not come up with anther example from the top of my head

  13. Guus

    Ok, thanks.

  14. flow

    Guus, may I ask what the outcome of this question influences?

  15. Guus

    Openfire currently discards any namespace/prefix definitions on the stream tag. This is causing some issues while refactoring our s2s code (notably around dialback). From there, I got curious.

  16. moparisthebest

    It's nice to be able to treat every stanza/nonza as it's own document

  17. moparisthebest

    For a lot of reasons, not the least of which is security

  18. Guus

    That's why Openfire discards the root element (after some validation). Downside is that those namespace definitions are lost.

  19. Guus

    I was kind of surprised that that hasn't caused any issues that caused people (likely: third party devs) to reach out.

  20. Zash

    I imagine most XMPP devs have been avoiding that because of implementations with custom XML parsers that are picky about the stream header, or doesn't keep ns prefixes.

  21. Daniel

    When I first started with xmpp my stock xml serializer would always put all namespace as prefixes into the stream opening element. But I quickly learned not to do that after comparing it to what I saw in the gajim xml console

  22. singpolyma

    Could save some bytes I expect, but probably not very many per stanza

  23. Zash

    In some cases like XEP-0198 you could save a lot on relatively small and highly frequent elements.

  24. Link Mauve

    Zash, a stanza smaller than an ethernet frame will not reduce the size of transmission in any way.

  25. flow

    moparisthebest, you can still threat every top level stream element as its own document and still support namespace prefix definitions in the enclosing <stream/>

  26. Link Mauve

    But I plan on finishing a XEP for advertising as a server that you support this feature, which could indeed help kickstart clients to do it.

  27. flow

    moparisthebest, you can still treat every top level stream element as its own document and still support namespace prefix definitions in the enclosing <stream/>

  28. flow

    > Link Mauve> Zash, a stanza smaller than an ethernet frame will not reduce the size of transmission in any way. Huh? if you send 90 bytes payload, the ethernet frame will be 90 bytes + tcp header + ip header + ethernet header? What am I missing?

  29. Link Mauve

    flow, whether the result is 90+some bytes or 1500 bytes the same amount of data will be transmitted.

  30. moparisthebest

    flow: only if you keep around some state, then you gotta remember when to clear it

  31. Link Mauve

    If it is 1501 bytes two frames will be transmitted, so you will have sent twice as much as 1500 bytes.

  32. Link Mauve

    moparisthebest, easy: on </stream>.

  33. flow

    moparisthebest, sure, but that's like not rocket science?

  34. Link Mauve

    (Or connection loss.)

  35. Guus

    Link Mauve, are you talking about MTU?

  36. Zash

    Is keeping a map of prefix→namespace that much? Think of it as HPACK maybe? ;)

  37. Link Mauve

    Guus, yes.

  38. Guus

    I always assumed that this was the _maximum_ allowed size in one data packet, but not a fixed size.

  39. moparisthebest

    flow: idk, it's the cause of gzip compression not being secure for instance

  40. Link Mauve

    Guus, hmm, that’s not what I got taught at uni, but now I’m starting to doubt.

  41. Guus

    as in, I assume that you can sent _less_ data. Sending less data with more packets incurs overhead of packet metadata, which is why you'd want to use up as much of the MTU as you can. I did not know if _not_ doing that causes all of the 'remaining' space to be used up by explicitly sent data.

  42. flow

    moparisthebest, I think we are talking about different things here

  43. moparisthebest

    Plus you have to *not* keep anything around for WebSocket

  44. Guus

    Link Mauve: I very much am _not_ an expert here, so there is a good chance that I am very wrong.

  45. Link Mauve

    Me neither, which makes me doubt even more. :)

  46. Link Mauve

    And I don’t even know how to start to measure that, perhaps saturate a link with just-MTU size and then saturate it with as small a packet as possible, and compare the throughput?

  47. flow

    tcpdump?

  48. flow

    besides the name, it actually captures ethernet traffic, so it shows everything down to the ethernet frame

  49. Link Mauve

    That’s one layer too high, we want physical ethernet frames.

  50. Link Mauve

    Oh?

  51. flow

    so does wireshark

  52. moparisthebest

    I'm simply saying keeping state around is always more dangerous than not keeping state around

  53. thilo.molitor

    Link Mauve: no, you definitely can send packets and Ethernet frames smaller than your MTU...those won't get magically filled up with padding bytes ;)

  54. Zash

    Keeping state around is what makes XMPP efficient IMO

  55. flow

    moparisthebest, I am not sure if I would agree

  56. Zash

    Creating a whole new XML parser for each message seems meh.

  57. flow

    Zash, why?

  58. Zash

    flow, don't have to say things the other end already knows (because it keeps state)

  59. thilo.molitor

    TCP will try to fill it's packets up to the MTU, but only if there is enough data waiting to be sent in its buffers...otherwise it will send smaller packets...

  60. flow

    Zash, In my case, I keep the state by synthesizing a wrapping <stream/> around the top level element before handing it to the parser

  61. flow

    Zash, In my case, I keep the state by synthesizing a wrapping <stream/> around the top-level element before handing it to the parser

  62. thilo.molitor

    Monal creates one XML parser and can use any namespace prefix defined on the stream header anywhere in the stream...

  63. Zash

    we do something like that for WebSocket

  64. Zash

    or did we?

  65. Zash

    maybe it was BOSH

  66. thilo.molitor

    flow: why don't you use a single streaming parser and feed in data as it arrives?

  67. flow

    because denial of service attacks due the missing isolation

  68. flow

    so basically a top-level stream element is send from one entity

  69. thilo.molitor

    What missing isolation?

  70. flow

    if you parse multiple stream elements with the same parser, then, due the missing isolation, one entity can affect another entity

  71. flow

    that's the high level view of it

  72. thilo.molitor

    Isn't parsing a stream header for every incoming stanza much more overhead --> more dos potential?

  73. flow

    but maybe things will become clearer if I post the DoS in Smack that the Jitsi folks discovered

  74. Zash

    The same for all users?

  75. Zash

    Don't do that

  76. moparisthebest

    WebSocket with each stanza being explicitly framed is a much better way to do it, we should start doing the same over TLS/QUIC

  77. flow

    thilo.molitor, the stream header is trivial to parse and from an trusted entity

  78. moparisthebest

    Ie prefixing each stanza with a length

  79. thilo.molitor

    > The same for all users? > Don't do that No, one parser for every TCP stream of course

  80. Guus

    hasn't Jitsi published that yet, Flow?

  81. Guus

    (I agree, it makes a strong case for not carrying over state).

  82. flow

    No, one parser of every top-level stream element ;)

  83. thilo.molitor

    > if you parse multiple stream elements with the same parser, then, due the missing isolation, one entity can affect another entity > that's the high level view of it But as s2s client, if you don't trust your server all bets are off anyways, no?

  84. thilo.molitor

    *c2s

  85. flow

    but really, it depends on the parser you use how much DoS'y it gets

  86. flow

    in Smack's case, it was ironically StAX's DoS protection that makes the connection DoS'able

  87. singpolyma

    moparisthebest: the grip Oracle thing specifically relies on the attacker injecting significant content into the compressed stream. Only affects xmpp in the case of error stanzas mostly

  88. thilo.molitor

    > No, one parser of every top-level stream element ;) I don't really get it...you use one parser for all TCP connections?

  89. thilo.molitor

    singpolyma: we could just compress every stanza independent of others, wouldn't that eliminate the oracle risks more or less?

  90. flow

    No, I create a new parser for every top-level stream element

  91. thilo.molitor

    > No, I create a new parser for every top-level stream element Is that a server or client?

  92. singpolyma

    thilo.molitor: yes, of course

  93. thilo.molitor

    For a client I won't assume the server tries to dos me...

  94. Zash

    thilo.molitor, just be sure to never connect to moparisthebest's servers then ;)

  95. thilo.molitor

    singpolyma: then someone just has to write a new xep for that ;)

  96. thilo.molitor

    > thilo.molitor, just be sure to never connect to moparisthebest's servers then ;) :D

  97. singpolyma

    thilo.molitor: or just the code. The existing xep and/or tls compression cover it

  98. flow

    thilo.molitor, client in my case, but I believe a server should do the same

  99. flow

    esentially servers are more exposed to unvalidated input as clients are

  100. singpolyma

    It's just an implementation consideration to flush after every error stanza or on error stanza or whatever model you want to choose

  101. Zash

    I definitely remember langsec folks saying the XML way is better than lenght-prefixed protocols for security reasons. So I will remain skeptical to framing, and especially websockets.

  102. flow

    but in XMPP, servers tend to just route through invalid / dangerous data to clients if they do not need the data for routing purposes, so clients also get a lot of questionable input

  103. Zash

    flow, define "invalid / dangerous data" ?

  104. thilo.molitor

    flow: but from a client perspective a server can easily do wild things like always close the connection after authentication or whatever...what I want to say is: if, from a client perspective, you don't trust your server, all bets are of anyways....

  105. thilo.molitor

    singpolyma: I'd do it after every stanza/nonza

  106. thilo.molitor

    > flow, define "invalid / dangerous data" ? Yes, please

  107. moparisthebest

    Zash: to be clear I'm saying length prefix is best, I just mentioned WebSocket cause that's basically what it does

  108. moparisthebest

    I can't think of a problem with a length prefix, but many vulns have happened because we don't have it

  109. flow

    https://discourse.igniterealtime.org/t/denial-of-service-vulnerability-in-smack-4-4-if-xmpptcpconnection-is-used-with-stax/92314

  110. flow

    Zash, invalid could mean multiple things, for example schema says attribute value is int but it actually contains "foo"

  111. Zash

    Aren't there vulns because of them too?

  112. jonas’

    moparisthebest, question 1: how many bits would you reserve for the length prefix? question 2: how do you detect and handle the case where you got out of sync with the length prefix, e.g. because a faulty remote implementation swallowed a byte somewhere? question 3 (somewhat related to 2): which endianess? question 4: how to prevent people from passing it right into malloc() without thinking?

  113. flow

    dangerous could be something that triggers the dos protection of your XML parser ;)

  114. jonas’

    (pro tip: use an XML parser which doesn't need DoS protections because it doesn't support entities or whatever)

  115. flow

    well in JAXP's case, the limits where cummulative…

  116. flow

    and not just entity exansion, but also things like max attributes

  117. flow

    the commulative nature make the thing worse if you parsed the whole XMPP stream as a single document

  118. flow

    the commulative nature makes the thing worse if you parsed the whole XMPP stream as a single document

  119. jonas’

    if you parse an XMPP stream into a document, that's your first mistake

  120. flow

    I know, that's why I don't do it ;)

  121. flow

    or maybe "into a document" has a differnt meaning for me as for you

  122. flow

    Smack's code before me used to threat the whole XMPP stream as a single document using a single parser

  123. jonas’

    if you end up with something DOM-like which contains the stream header

  124. jonas’

    creating separate parser things for every stanza is another way to screw things up

  125. flow

    well it's pull parsing, so it's not dom-like

  126. jonas’

    that's got nothing to do with one another

  127. jonas’

    you can have a pull parser which creates a DOM

  128. jonas’

    you can have a SAX parser which is fed into a DOM generator

  129. jonas’

    the only sensible way, which won't lead into valleys of pain and sorrow, is using a streaming parser and to parse the entire stream in a single parser state

  130. flow

    fwiw, I did not run (yet) into any issues with the splitting approach

  131. jonas’

    namespace prefixes?

  132. flow

    but ymmv

  133. flow

    well that is what we discussed initially

  134. jonas’

    sorry, late to the party I am

  135. jonas’

    that would be one issue though :)

  136. flow

    if you want to support them, then you have to suppor them, but its not rocket science

  137. flow

    if you want to support them, then you have to support them, but its not rocket science

  138. jonas’

    even with just the default namespace, it implies having to use some weird parser for the stream header (one which exposes prefixes and so on to the application layer, which is yet-another-way to make ones life harder with XML)

  139. flow

    not sure where it implies to use some weird parser

  140. jonas’

    (namespace prefixes shouldn't matter and you should just not even receive them from the parser; though being able to set them is sensible for legacy compatibility)

  141. jonas’

    flow, how would you otherwise learn the default namespace, given that the stream header is decidedly not in that namespace?

  142. jonas’

    that requires a weird parser.

  143. jonas’

    alternatively you can not care about that, of course, and ignore unconforming implementations and just hope it's jabber:client/jabber:server matching the connection type.

  144. flow

    it's been probably 3-4 years ago when I wrote the code, let me see what crimes I did ther

  145. jonas’ backs away slowly

  146. flow

    jonas’, not sure if I understand your question regarding the "default nnamespace"

  147. flow

    at some point I get the stream open tag, and there will be a xmlns in it?

  148. jonas’

    exactly

  149. jonas’

    no sensible parser should give you the contents of that attribute

  150. jonas’

    to protect you from hurting yourself

  151. flow

    that attribute being 'xmlns'?

  152. jonas’

    yes

  153. flow

    ok, I am not sure why a parser shouldn't reveal the contents of the attribute, but in my case, the stream open is in fact not processed by a parser, but by jxmpp's XML string splitter, it is special cased one could say

  154. jonas’ backs away more quickly

  155. Zash

    So in case anyone was wondering why we don't use some XML features, this is why. :)

  156. flow

    hmm?

  157. moparisthebest

    jonas’: 1. 24 bit would be enough but maybe 32 to not be odd... 2. This isn't a problem is it? If you read length and it's not valid XML, close stream 3. Network endianess 4. Well it's trivial, and you can reuse buffers, unlike now where people dynamically grow allocations (and it plays better with GC langs)

  158. flow

    That was in particular build allowing for XML features like namespace declartions in <stream/> for reduced bytes on the wire

  159. Zash

    moparisthebest, I'm afraid what will happen if I tell you this, but you could probably get away with chunked content encoding from HTTP (hex encoded length prefixes) since text between stanzas will likely be ignored

  160. flow

    That was in particular build allowing for XML features like namespace declartions in <stream/> to reduce the bytes on the wire

  161. moparisthebest

    Zash: hmm probably true... Though I'm not sure it's very helpful if it's optional, I was thinking it'd be advertised on the connection level, ie you'd know before connecting

  162. singpolyma

    A length prefix on regular stanzas seems redundant, but it would be neat to have a way to switch to "this is binary now" with a length prefix to allow arbitrary binary content in almost-xml without base64

  163. Zash

    moparisthebest, well if you do things like that, stream feature and negotiate it

  164. flow

    or EXI it

  165. thilo.molitor

    > well in JAXP's case, the limits where cummulative… Isn't that dos protection having upper limits for the entire stream moot anyways? I mean at least in the xmpp context you'd process a stanza and then forget about it...and I think many streaming XML protocols do the same...

  166. thilo.molitor

    So isn't turning off these global limits a better dos protection than trying to split the XML string into its stanzas/nonzas on the string level with something not a true XML parser just to concatenate this string chunk with another containing the carved out stream header and then feed that whole thing into a true XML parser?

  167. thilo.molitor

    flow: Seems overly complicated and error prone to me...

  168. thilo.molitor

    If your parser could only do global limits rather than per stanza limits, you maybe should use another parser (maybe something written in rust?)

  169. flow

    thilo.molitor, I am not sure if I would describe it as overlay complicated myself. I belive you need some first parsing step that enforces stanza limits, and then the <stream/> handling is trivial

  170. flow

    at least that was my experience when I implemented it

  171. flow

    and I also found that this low-level, featureless XML parser that does the XML splitting to be fairly easy to implement

  172. flow

    especially if you only have to take care of valid-XMPP XML

  173. flow

    thilo.molitor, I am not sure if there are may further XML streaming protcols besides XMPP fwiw

  174. flow

    I am not sure about SOAP, but I believe SOAP messages are freestanding

  175. singpolyma

    There have been streaming atom over http things in the past, but most of those are streaming json now

  176. flow

    globally turning off the limits in JAXPs case is problematic if JAXP is used elsewhere in the same application/(JVM instance) where they are required. in some cases, you can't simply turn them off globally

  177. flow

    and sadly JAXP has no way to configure pre-parser limits

  178. flow

    and sadly JAXP has no way to configure per-parser limits

  179. flow

    and wrt RIIR: I'd rathyer stay in the JVM ecosystem and this makes the whole thing portable

  180. moparisthebest

    I think using a general purpose XML library rather than an XMPP specific one is also always a mistake

  181. flow

    but really, the main argument is that it's sensible split the incoming stream in individual top-level stanzas for isoliation purposes, then the limits of the actual XML parser do not really matter, as they are probably higher than the usualy maximum stanza limit (which I believe is currently in the range from 64 KiB to 1 MiB)

  182. flow

    moparisthebest, that's a bold statement, why no re-use existing libs as building block?

  183. flow

    i'd assume that implementing your own XML parser is far more error prone, especially if done in an unsafe language

  184. moparisthebest

    A long and continued history of security vulnerabilities has proven it to be a mistake

  185. Menel

    He didn't say build your own.. But use one that doesn't have the 90% you'll never need

  186. flow

    so because others are unable to implement a XML parser securely you have to do it yourself because you will not make any mistakes?

  187. moparisthebest

    general XML parsing is very very complicated and full of demons, parsing the small subset of XML that XMPP uses not so much

  188. flow

    I think most XML parser are able to be configured to use the sensible XML defaults that XMPP requires, some of them are even configured out of the box that way

  189. flow

    it's really not that much, many of the issues are due to entity references and external entities, disablem them and you eliminate many error causes

  190. flow

    it's really not that much, many of the issues are due to entity references and external entities, disable them and you eliminate many error causes

  191. singpolyma

    moparisthebest: why would you need something xmpp specific?

  192. flow

    but those are not really much about parsing, more about XML transofrmation

  193. singpolyma

    I'm not aware of any "subset" that xmpp uses. Unless you mean we don't use doctypes

  194. moparisthebest

    singpolyma: because it has about 999x less code than a general XMPP parser and therefore 999x less bugs

  195. moparisthebest

    singpolyma: because it has about 999x less code than a general XML parser and therefore 999x less bugs

  196. flow

    singpolyma, if I understand moparisthebest correctly, then he assumes that a parser that only implements the XML stuff required for XMPP is superior

  197. flow

    compared to using a "standard" XML parser

  198. singpolyma

    flow: but that's ~all XML stuff afaik

  199. flow

    I am not sure if I can follow moparisthebest argument

  200. moparisthebest

    Yes, smaller and less buggy, which means more secure

  201. Zash

    singpolyma, entity declarations, comments, stuff like that

  202. flow

    if you use a niche XMPP XML parser, then this code probably gets less review than the real XML parser

  203. singpolyma

    Zash: declarations are doctype yeah. Does xmpp explicitly disallow comments???

  204. Zash

    I believe so

  205. flow

    and most standard XML parser can be configured in a safe XML way, which is "accidentially" just what XMPP requires from XML

  206. Zash

    If only I could link to sections in the RFC

  207. moparisthebest

    "less review" isn't a very good argument

  208. flow

    singpolyma, yes we disallow comments in the stream

  209. Zash

    singpolyma, https://xmpp.org/rfcs/rfc6120.html#xml-restrictions

  210. flow

    but I am not aware of any security issue wrt to XML comments (happy to be proven wrong)

  211. singpolyma

    That's insane and dumb but ok

  212. moparisthebest

    flow: maybe they can be but a massive source of CVEs is when they accidentally aren't

  213. moparisthebest

    This isn't conjecture I'm just looking at history

  214. flow

    the realy XML mine field are entity references and processing instructions

  215. singpolyma

    I mean, processing instructions are mostly just comments

  216. singpolyma

    Unless you define some that you understand

  217. singpolyma

    And yeah, doctypes are a while different thing we obviously don't need

  218. flow

    the real XML mine field are entity references and processing instructions

  219. singpolyma

    And yeah, doctypes are a whole different thing we obviously don't need

  220. moparisthebest

    flow: comments are a security issue when different things interpret them differently, ie your parser thinks something is commented out and mine doesn't etc, also a very common vuln in parsers of all types

  221. flow

    moparisthebest, but i've never heard of XML comments being ambiguous?

  222. flow

    you are right in general of course, that this is the typical problem of (human-readable) comments in documents for machines, but I never heard that this was an issue in XML (again, happy to be proven wrong)

  223. Zash

    What is the use case for comments in a network protocol?

  224. flow

    there is none, but it's probably also the XML feature with the smallest attack surface

  225. flow

    still, I lean towards that it is sensible to forbid them in XMPP

  226. singpolyma

    Zash: same as anywhere else. For humans to betters understand when reading

  227. Zash

    I'm not aware of comments allowed .. outside of email, which seems like an argument to forbid them.

  228. flow

    eeehhh, maybe, but in my year working with XMPP I never thought "hey, it would be great if this XMPP stream had comments"

  229. flow

    and even then, you can immitate comments by using custom extension elements

  230. flow

    and, most importantly, provide <error/> with a good textual description that reflects the internal state of the implementation emitting the error, aiding debugging

  231. flow

    (of course without leaking any secrets ;))

  232. flow

    *in my years working with XMPP

  233. singpolyma

    flow: sure. But also pretending we use a "subset" of XML when no one is hand rolling an XML parser seems just asking to be violated. I expect most implementations allow comments because there's no reason not to

  234. Zash

    Relevant https://modules.prosody.im/mod_conformance_restricted.html

  235. flow

    singpolyma, I believe you are right about this assumption, but like to point out that jxmpp XML splitter bails on comments (for that exact reason)

  236. flow

    singpolyma, I believe you are right about this assumption, but like to point out that jxmpp's XML splitter bails on comments (for that exact reason)

  237. moparisthebest

    flow: https://bugs.chromium.org/p/project-zero/issues/detail?id=2254 is a good example of even raw XML being "ambiguous" and yet another reason for length prefixed stanzas

  238. Zash

    https://hg.prosody.im/trunk/file/0.12.1/util/xmppstream.lua#l228

  239. moparisthebest

    Gloox still hasn't been fixed by the way

  240. moparisthebest

    Fwiw I agree stanzas should be split from the stream before sending to an XML parser https://github.com/moparisthebest/xmpp-proxy/blob/master/src/stanzafilter.rs length prefixes sure would make it simpler though

  241. singpolyma

    Was expat fixed?

  242. moparisthebest

    I believe I asked at the time and ejabberd's fastxml and/or expat was fixed

  243. singpolyma

    Both of the bugs seem to come from hand rolling utf8, which I guess is the sort of thing you have to do in C

  244. flow

    moparisthebest, well it is ambigous to broken implemetantions, but then all bets are off. I was thinking about someting like https://trojansource.codes/

  245. flow

    moparisthebest, fwiw, I can totally get behind the idea of length prefixes for top-level elements in XMPP 2.0

  246. singpolyma

    Then everyone would *have* to hand roll parsers :P

  247. flow

    no

  248. flow

    well yes, the first level parser

  249. flow

    that extracts the length prefix and an XML string

  250. flow

    but then you can use an off-the-shelf XML parser for parsing the XML string

  251. moparisthebest

    flow: ha yea that was the kind of thing I was thinking about, nice website

  252. singpolyma

    flow: hopefully you wouldn't actually allocate a string for the XML data!!!

  253. flow

    singpolyma, hmm?

  254. moparisthebest

    Yea but you already have to roll your own first level parser, it's just hard vs reading a length

  255. flow

    I think I would, and do

  256. singpolyma

    The way you described it made it sound like you would read <length> bytes off the stream into a string and then feed them into a parser

  257. singpolyma

    Which is pretty awful

  258. flow

    it is *harder* then reading a length and the filling a buffer until the length is reached

  259. flow

    singpolyma, why is it pretty awful?

  260. singpolyma

    Because you need to store the while stanza in ram

  261. flow

    right, so?

  262. flow

    stanzas have to have an upper limit

  263. flow

    we are not sure where the limit should be, but I think it's between 64 KiB and 1 MiB

  264. singpolyma

    Only because people implement things in this way :P

  265. moparisthebest

    Ideally you'd have a pool of buffers to read stanzas into, and never resize them

  266. flow

    sure 1 MiB is probably not something your embedded microcontroller can handle

  267. flow

    that's why I personally would prefer a smaller maximum stanza size, probably around 128 KiB

  268. singpolyma

    If you have a parser already there's no reason to buffer the entire content. In any format or protocol. This is why we have streaming parsers

  269. moparisthebest

    max_stanza_size_bytes = 262_144

  270. Zash

    And then we don't need no length prefixes either

  271. moparisthebest

    Sorry that's what it is forever

  272. moparisthebest

    the entire federated network agrees

  273. singpolyma

    I thought I was lower than that?

  274. flow

    singpolyma, I don't think that this is true

  275. Zash

    Thinking of the 10k number?

  276. singpolyma

    Oh no, I'm forgetting base64 overhead

  277. flow

    you need to buffer the entire top-level stream element for processing after parsing, in one representation or the other

  278. Zash

    Yay, 3x memory usage right there!

  279. flow

    Zash, 2x I'd say

  280. flow

    but, yeah, you could tripple buffer

  281. Zash

    1x for the buffer, 1x for the collapsed string, 1x for the parsed representation.

  282. singpolyma

    flow: depends on your application. A server for instance does not since it can just copy the bytes to the target stream once it know which that is so needs only some small state derived from the parser events not the whole thing

  283. flow

    Zash, in my approach, the collapsed string is the buffer

  284. moparisthebest

    I'm told some past server did that singpolyma

  285. flow

    singpolyma, that's dangerous for the server to do

  286. moparisthebest

    Sounds fun for running clients out of memory

  287. flow

    because what if the sender suddenly becomes very slow

  288. flow

    yet you already started to feed the send data into the receiving sink?

  289. moparisthebest

    Ooh yea and the slowloris, good point flow

  290. flow

    XMPP servers have to store-and-forward

  291. singpolyma

    moparisthebest: that's the client's problem :)

  292. flow

    just like ethernet switches ;)

  293. moparisthebest

    They don't have to, but probably should

  294. singpolyma

    Probably should avoid I think you mean

  295. moparisthebest

    You could totally ruin s2s links as a client that way

  296. moparisthebest

    I'll send half a stanza then just never finish lol

  297. moparisthebest

    What does the server do to recover?

  298. flow

    essentially XMPP is totally borked when it comes to queuing discipline

  299. flow

    how should a server behave if a client suddently starts to receive data veeerrry slowly?

  300. singpolyma

    flow: how does the client receive speed affect the server at all? Just keep putting bytes in the socket

  301. flow

    (that is basically the reverse of the "Slow HTTP Attack")

  302. flow

    singpolyma, if a clients does not drain its outgoing buffer on the server side, then the buffer either grows identifently OR

  303. flow

    singpolyma, if a clients does not drain its outgoing buffer on the server side, then the buffer either grows indefinitely OR

  304. Zash

    flow, `<sm:a/>` times out, it gets kicked

  305. flow

    or it has to put backpressure on some other entities in the network (which is bad)

  306. flow

    or it has to drop stanzas (which is also bad)

  307. flow

    all three options in that scenario are bad and we have no solution

  308. singpolyma

    I... Don't think that's how it works? Server side writes the packets to network they don't need to buffer there?

  309. moparisthebest

    singpolyma: I'm talking about a client A sends a stanza destined for a remote server, or even another client on the same server, if the server starts streaming the stanza before client A finishes, what does the server do if client A never finishes?

  310. flow

    singpolyma, of course there is a buffer and/or the write() will block

  311. Zash

    open 3000 s2s connections!

  312. singpolyma

    moparisthebest: right. That's an interesting case. And of course one could argue that mam requires storing it anyway, so maybe that's the right initial sink.

  313. flow

    fwiw, there is a fourth option which is, I believe, employed by most serious XMPP servers: drop clients that are to slow

  314. flow

    probably not ideal, but obviously has served us well so far

  315. flow

    still, I'd love to see a better solution, but this probalby requires a fundamental different approach from XMPP

  316. moparisthebest

    But if they only sent half a stanza and you already started sending it down other streams then you have to close *all* the streams

  317. Zash

    In normal Instant Messaging, being slow enough to run into these kinds of problems is rare, so if it does happen it's likely the connection is borked and closing it is the thing to do

  318. flow

    basically the solution is that clients to not get data pushed, but that they pull, and that most state resides on the server (which is similar to djb's mail 2000 approach)

  319. flow

    Zash, the problem is that it is often not the client being slow, but the others being to fast

  320. Zash

    flow, what's that? send notifications and then clients (and servers) poll?

  321. flow

    something like that: the server sending just a tiny bit of notificaton that causes the client to initiate a poll

  322. flow

    really nothing that we will probably see soon (or ever) in XMPP

  323. Zash

    Sounds like a great way to build a self-inflicted DDoS machine

  324. flow

    how?

  325. Zash

    It changes the rate of things to depend on the receivers instead of the sender, so if you host on underpowered hardware (as some do because XMPP is very efficient).

  326. flow

    yep, that's the pill you have to take. as I wrote, most state is on the server then

  327. flow

    which would then, as yout pointed out, required stronger server machines

  328. Zash

    Affects mostly broadcast things like chat rooms tho

  329. flow

    but in my vision, every family and/or household hosts its own service (or uses some sort of provider that operates if for them at home or at a cloud)

  330. flow

    and then the load on the server should be not really significant, as the number of users is low, and by that the state is not that big

  331. flow

    fwiw, that is also why I ♥ IMAP

  332. Zash

    Adding a bunch of roundtrips just to receive a small chat message seems unwarranted.

  333. Zash

    Tho it is, in effect, what you get on iOS and other restricted mobile settings.

  334. flow

    jonas’, to pick up a previous topic: could you elaborate why a user learing about the value of the default namespace would lead to potentially hurt the user?

  335. singpolyma

    flow: they might try to use it for something instead of letting the XML lib handle it

  336. emus

    Hey folks, would be great to one or the other reviewer! https://github.com/xsf/xmpp.org/pull/1209 We still don't know all contributors

  337. ralphm

    emus: Regarding your request on changing the Monal feed on Planet Jabber, I have a question. What is the difference between monal.im and monal-im.org? I see the latter is newer, but it is kinda confusing.

  338. emus

    ralphm: Monal changed their owners and made an entire new website CC thilo.molitor

  339. emus

    .im is outdated? see last blogpost

  340. emus

    .im is outdated, see last blogpost

  341. ralphm

    ok

  342. moparisthebest

    Woo DNSSEC