#2 Re: mORMot 2 » Security Problem with Session Cookie » 2025-04-16 10:02:51

Hi As BUGFix i commented the Lines 1539-1541 in mormot.rest.mvc

  result := fContext.Validate(
    cookie, PRecordData, PRecordTypeInfo, PExpires, nil, Invalidate);
//  if result <= 0 then
//    // delete any invalid/expired cookie on server side
//    Finalize;
end;

#3 Re: mORMot 2 » Security Problem with Session Cookie » 2025-04-16 09:11:50

ab wrote:

Please try with tonight's code.

It should keep track of the finalized sessions, and reject them.
I also switched the cookie signature and encryption to AES-GCM-128 which is both very fast and cryptographically secure.
As far as I can tell, there is no advantage of using a JWT in respect to our TBinaryCookieGenerator now.

Hi Arnaud, sorry i testet wrong. The Problem was not solved correctly.
I didn't provide function for fApplication.OnSessionFinalized so invalidate was not called.

But if i provide function there is an Stack Overflow generated because finalize is called recursive.

#4 Re: mORMot 2 » Question: Modifying OutCustomHeaders in GetViewInfo ? » 2025-03-21 09:22:53

I think both Variants are to complicated. I genereate ContentSecurityPolicy in GetViewInfo which generates 2 Nonce Values for script and style
This both values i give to mustache {{main.cspnonce}}

if i use callback it is called after mvc, how could i add my nonces to main.xy ?
if i use ttomas version i have to add my code to every function, i have a lot

To make it easy, i made a little patch to TRestUriParams and added a new value: ContentSecurityPolicy

   LowLevelUserAgent: RawUtf8;
    /// itSDS: für ContentSecurityPolicy !
    ContentSecurityPolicy: RawUtf8; // itSDS
    /// initialize the non RawUtf8 values
    procedure Init; overload;

Then i added a little bit of code to mormot.rest.http.server.pas

  call.LowLevelUserAgent := Ctxt.UserAgent;
  call.ContentSecurityPolicy := ''; // itSDS
  if fHosts.Count > 0 then
  Ctxt.OutCustomHeaders := call.OutHead;

  if call.ContentSecurityPolicy <> '' then // itSDS
    Ctxt.AddOutHeader(['Content-Security-Policy: ', call.ContentSecurityPolicy]);

  if call.OutInternalState <> 0 then

what do you think ?

#6 mORMot 2 » Question: Modifying OutCustomHeaders in GetViewInfo ? » 2025-03-20 19:26:16

itSDS
Replies: 5

Hi Arnaud, i like to add a different nonce for CSP to every call of GetViewInfo
Acually I put my CSP to OutCustomHeaders in HttpServer Request.

is it Possible to Access / Modify the Ctxt.OutCustomHeaders from MVCApplication ?

Thank you

#7 mORMot 2 » RS12.3 64Bit ComputeRoutes takes 99s in DEBUG Mode » 2025-03-19 11:19:19

itSDS
Replies: 1

I Start Service compiled for 64Bit in Debug Mode, it seems to hang, but in Log i can see that ComputeRoutes takes 99s to start.
Starting same Service from Command Line starts immediate as expected.

i saw thsi Problem before but not taking so long...

#8 Re: mORMot 2 » Delphi 12.3 doing timeout error starting server » 2025-03-19 11:00:56

Sry i must correct me, I changed above line without effect. Make new Ticket for my problem

#9 Re: mORMot 2 » Bug with Log To SynLz » 2025-03-19 10:15:23

After disabling the AntiVirus, the Problem does not happen again, may there was a problem with the AV ?!

#10 Re: mORMot 2 » Missing function NetConcat » 2025-03-19 10:12:20

I think you renamed it to mormot.core.base.concat

#11 mORMot 2 » Missing function NetConcat » 2025-03-19 10:03:53

itSDS
Replies: 2

Hi Arnaud, in latest version NetConcat is missing in mormot.net.http.pas

#12 Re: mORMot 2 » Security Problem with Session Cookie » 2025-03-19 09:45:06

There was one thing, happened to me smile
I changed CookieName to "DIT Test" and later got error in Reverse Proxy:

  Description
  This violation occurs when HTTP cookies contain at least one of the following components:
  - Quotation marks in the cookie name.
  - A space in the cookie name.
  - An equal sign (=) in the cookie name.
  Note: A space between the cookie name and the equal sign (=), and between the equal sign (=) and cookie value is allowed.
  - An equal sign (=) before the cookie name.
  - A carriage return (hexadecimal value of 0xd) in the cookie name.

may be there should be a Check-Routine in SetCookieName throwing Exception if name does not match the rules für Cookie Names smile

#13 Re: mORMot 2 » Security Problem with Session Cookie » 2025-03-19 09:38:13

Hi Arnaud i testet it today an it seems to be secure now, could not use deletet Cookie any more.

#15 mORMot 2 » How Get RemoteIP correctly ? » 2025-03-17 18:36:57

itSDS
Replies: 1

Hi Arnaud,

i try to get RemoteIP in MVC Server.
I set RemoteIPServer either to X-Real-IP or X-Forwarded-For.

But how can i access/Request RemoteIP from function in MVC-Server ?

i tried it this way:

function TMyMVCApplication.GetCallerIPAdresse: RawUtf8;
begin
  Result := FindIniNameValue(pointer(ServiceRunningContext.Request.Call.InHead), 'REMOTEIP: ');
  if Length(Result) = 0 then
    Result := ServiceRunningContext.Request.Call.LowLevelRemoteIP;
  if Length(Result) = 0 then
    Result := '127.0.0.1';
end;

But RemoteIP is empty

Thank you

#16 Re: mORMot 2 » Bug with Log To SynLz » 2025-03-13 19:05:54

I was just looking fpr a reason, that the Log Files behave the described way.
The Problem is, if the BUG occurs, the Service seems to hang for the connected clients

#17 Re: mORMot 2 » Bug with Log To SynLz » 2025-03-13 11:32:11

Hi Arnaud, today we had this Problem again, consuming also a lot of cpu cycles in the service with the Log - Problem.

I found out, that on the server running the logs, Microsoft defender was scanning the logs.
Is this a possible Reason for the Problem?
I deaktivated the Defender - Scan for our Log/Service directories.

I will report if Problem has gone or not

#19 Re: mORMot 2 » Custom SQL Queries Creating New Connections » 2025-03-12 08:15:47

In MySQL we increased the number of allowed connections, may be there is an option in PostgresSQL

#20 mORMot 2 » Security Problem with Session Cookie » 2025-03-11 20:05:31

itSDS
Replies: 10

Hi Arnaud, a Pentester has tested our mvc Server !

He found this vulnerability:

He saved the Session Cookie on client Site. Logged out frrom Server (On Server CurrentSession.Finalize is called and client Cookie Removed)
But after this he used the saved Cookie to call MVC - Pages.
The Cookie is still valid.

Do you know a simple way to invalidate such cookies ?

We Create Session Cookies after Login-Funktion with CurrentSession.Initialize and check it with CurrentSession.CheckAndRetrieve

Thank you

#21 Re: mORMot 2 » Json - Passing Variant a record » 2025-03-11 07:01:06

May be its better to use TObject instead of record than null in val should be possible

#22 Re: mORMot 2 » unexpected request timeouts » 2025-03-04 11:00:19

Hi Arnaud, i',m back from holiday, did you change something i can test ?
atm we switched back to standard server implementation

#23 Re: mORMot 2 » unexpected request timeouts » 2025-02-07 12:42:23

Hi Arnaud yes i think daniel has an other problem.
I sent you new Logs today with low level logs
And yes my Problem is primary with big data packets (exact size unkown) but its reproducable in different client server scenarios.

#24 Re: mORMot 2 » unexpected request timeouts » 2025-02-04 08:17:12

Hi Arnaud, i checked all of this:

ab wrote:

What do you call "request timeout"?
Is it a HTTP_TIMEOUT = 408 error code?

Yes

ab wrote:

On server side:
Is it visible on the server side, via TRestServerUriContext.ExecuteCommand() as TimeOut method - i.e. InternalLog('TimeOut %.Execute(%) after % ms' ?

No on Server site i can see nothing

ab wrote:

Do you use the HeaderRetrieveAbortDelay option?

No

ab wrote:

On client side:
It may come from a long SockReceivePending()=cspNoData line 2373 of THttpClientSocket from mormot.net.client.
Is it the case?

I don't know, i will add DoLog To OnLog

And the Connection is still alive - Server is responding to other clients
Client is sending next Request if i start any

The Only Thing i observed is, that the Packed is "bigger" lets say 600KB to 2MB

#25 Re: mORMot 2 » unexpected request timeouts » 2025-02-03 19:20:01

@AB yes its a 408 error. I made a documented client / Server / Log and sent it to you also.

#26 mORMot 2 » unexpected request timeouts » 2025-02-03 12:00:03

itSDS
Replies: 13

Hi Arnaud, this topic is not very easy, but i can not find the reason.

Using a m2 TRestHttpServer with WEBSOCKETS_DEFAULT_MODE and TRestHttpClientSocket only http connection
we get unexpected request timeouts on client site.

In Log we can see timestamp request to server, auth, instance and contract request.
But then using one of the interface function sometimes gives "request timeout"

On Server site we can see all as normal. but if request timeout nothing is in log on server site.
We checked firewall / content filter there should be nothing.

Do you have any idea what else we can check / Enable any extra log or so ?

#27 Re: mORMot 2 » Securing http server » 2025-02-02 19:01:46

Now i have ported Boilderplate to m2, just to let it run smile
I think your Code is Work in Progress !
The whole thing is very big so i understand, that other things are more important.

#28 mORMot 2 » Securing http server » 2025-01-28 19:49:53

itSDS
Replies: 1

Hi Arnaud,

i would like to make the http Server more secure and like to add this Options:

X-Frame-Options
Content-Security-Policy
Permissions-Policy
Cross-Origin-Embedder-Policy
Cross-Origin-Resource-Policy
Cross-Origin-Opener-Policy

I saw in mormot.net.http.pas some Options like in Boilerplate, but no implementation. Is it missing ?

#29 Re: mORMot 2 » How to Set secure attribute in cookie of MVC Application » 2025-01-20 13:57:35

Hi Arnaud, sounds good, is there an example of mutual Authentication available ?

#30 Re: mORMot 2 » How to Set secure attribute in cookie of MVC Application » 2025-01-20 11:55:16

One other question in this context, is it possible to crypt the traffic from client with syncrossplatform client to m2 server without using ssl.

as ssl can be compromitted with man in the middle attacks

#31 mORMot 2 » How to Set secure attribute in cookie of MVC Application » 2025-01-20 11:12:38

itSDS
Replies: 4

Hi Arnaud, we are asked to set secure Attribute for cookies, is this possible with m2 and how ?
ty

#32 Re: mORMot 2 » Bug with Log To SynLz » 2024-09-04 08:05:18

Sorry its

500*1024
or
1000*1024

#33 Re: mORMot 2 » Bug with Log To SynLz » 2024-09-03 19:10:23

In this case its 1000M but get same with 500M

The Content of the Log is nearly the same Just some lines added from file to file..

#34 Re: mORMot 2 » Bug with Log To SynLz » 2024-09-03 13:49:56

Hi Arnaud, here a some screens from the Logs, may be you understand now what i mean

https://imgur.com/a/ciHf8nj

I think there is a Problem in TSynLog.PerformRotation, May be the File can not be deleted or something else

#35 Re: mORMot 2 » Bug with Log To SynLz » 2024-08-30 08:54:58

Hi Arnaud, what do you mean ?

You need more details ?

The Problem occours not very often !

#36 mORMot 2 » Bug with Log To SynLz » 2024-08-27 12:26:05

itSDS
Replies: 11

Hi Arnaud,

today we had this Problem:

    TSynLog.Family.RotateFileCount := 100
    TSynLog.Family.RotateFileSizeKB := 500MB
    TSynLog.Family.RotateFileDailyAtHour := 23

LogSize : 946MB
And 100 Files Created each containing the Log with some few lines added

It seems that the Log is not truncated / deleted after creating the synlz
so that every synlz contains the Log beginning at the same Line but enhanced with some newly added rows.

After restarting the Service everything runs as expected

Any Idea ?

#37 Re: mORMot 2 » Question concerning "auto"-Retry » 2024-06-03 11:42:51

Ty for your answer, i understand that client should not wait long for answers smile

#38 mORMot 2 » Question concerning "auto"-Retry » 2024-06-03 11:20:09

itSDS
Replies: 2

Hi Arnaud, i found this topic: https://synopse.info/forum/viewtopic.php?id=6249

and have a similar problem.

On Client Side i prepare a lot of Data lets say 50000 Records.
I pass them as an array of Records thru a SOA Function
The Server needs 10min to work on this records.
so i have to set my Timeouts > 10min (Send/Receive/Connect)

else a retry will occur and send the Records again.

As you wrote in the topic the server should only use ms to answer.
What will be the best approach to realise this big task ?
Should i implement an own thread handling it and send notifications during processing to client ?

Also as in topic, debugging is anoying with the retry.
What is the reason to retry the sending of data ? Should this not be handled in the SOA Call.

#39 Re: mORMot 2 » Stack Overflow in LogView » 2024-05-22 09:23:03

Good Tip thank you very much

#40 Re: mORMot 2 » Stack Overflow in LogView » 2024-05-22 08:19:26

Hi Arnaud, today i had a litte bit of time to fix the Problem.

in my Code a had lots of
TSynLog.Add.Log(sllEnter, .... (Used in Class Procedure)
But there is no automatically genereted sllLeave

LogView uses a recursive function: ComputeProperTime to calc times
This was called to often.

i made to things:
1. i increased the Stack Size of LogView with Compiler Switch: {$M 16384,4194304}
2. i changed the sllEnter to sllDebug

How can i use sllEnter in class functions/procedures to get runtime ?
Should i manually add sllLeave ?

#41 Re: mORMot 2 » E10060 with THttpClientSocket and not with Winhttp Client » 2024-05-14 09:56:57

Just to end this Ticket, with OPENSSL Version the Connection coulf be establiched.

One Thing: if i copy only the first dll (libcrypto...) and Libssl is missing, the Error Message should be like: libssl.. is missing ...

#42 Re: mORMot 2 » E10060 with THttpClientSocket and not with Winhttp Client » 2024-03-22 08:25:42

Ty just to give more information:

On Server Side Client Connection works in both modes.
Only Clients connecting over Network get timeout error

OpenSSL is disabled, I'll try it using OpenSSL

#43 mORMot 2 » E10060 with THttpClientSocket and not with Winhttp Client » 2024-03-21 14:50:35

itSDS
Replies: 4

Hi i just switched from WinHttp to Socket client and get error 10060

Log Output

InternalUri GET
...
ESChannel {recv : Socket Error 10060}
ENetSocket {THttpClientSocket.DoTlsAfter: TLS failed ..

after a timeout of 30s

With WinHttp the connection can be established

We connect to a server with valid certificate.

I need a clou how to find the reason for the error- any thougths ?

#44 Re: mORMot 2 » Create SynCrossPlatform Wrapper with m2 broken » 2024-03-21 14:46:00

Hi thank you very much tomas, actually we have modified the mustache Template an can use it with m2. I ll report some things if we are finished

#45 Re: mORMot 2 » Create SynCrossPlatform Wrapper with m2 broken » 2024-03-20 08:39:03

Hi ttomas, thanks for the code. i directly testet it and have some results !

1. The nested records are fine now

but there are the following problems now:

1. the definition of all the dynamic array types is behind (under) the use of them in the previous defined records. (May be depending on the wrapper
2. in the variant2 and 2variant function there is something wrong added

would be easier to understand if i provide some graphics

Link with pictures

https://cloud.diestelmann-it-gmbh.de/s/LwSkbMAwJNTbD2S

#46 Re: mORMot 2 » Create SynCrossPlatform Wrapper with m2 broken » 2024-03-19 18:03:06

I testet today with the latest release - Same Error - Syncrossplatform Client can not be created with m2

#47 Re: mORMot 2 » Feature request or question concerning Certificate in Windows Storage » 2024-03-01 19:24:53

ty i tried my best but was a little confused converting from c to delphi. But now it works and certificate is found.

Now after getting the Handle the next error comes in AfterAccept:

Erste Gelegenheit für Exception bei $76CCDD80. Exception-Klasse ESChannel mit Meldung '<>: AcquireCredentialsHandleW returned 8009030E [2148074254], System Error 1312 [Eine angegebene Anmeldesitzung ist nicht vorhanden. Sie wurde gegebenenfalls bereits beendet]'.

Something about missing Credentials

#48 Re: mORMot 2 » Feature request or question concerning Certificate in Windows Storage » 2024-03-01 14:14:19

Yes certificate is in HKLM/Software/Microsoft/SystemCertificates/MY/Certificates

But CertOpenStore returns nil ...

May Be Something wrong with Parameters:

  CERT_STORE_PROV_SYSTEM = 10;
  CERT_STORE_MAXIMUM_ALLOWED_FLAG = $00001000;
  CERT_SYSTEM_STORE_CURRENT_USER =  $00010000;
  CERT_SYSTEM_STORE_LOCAL_MACHINE = $00020000;


    var LProvider : AnsiChar := #10; // CERT_STORE_PROV_SYSTEM  or CERT_STORE_MAXIMUM_ALLOWED_FLAG
    var LMy := 'MY';
    fAcceptCertStore := mormot.lib.sspi.CertOpenStore(@LProvider, 0, nil, CERT_SYSTEM_STORE_LOCAL_MACHINE, @LMy);

tried also with Admin rights / Ask for User also does not work.

#49 Re: mORMot 2 » Feature request or question concerning Certificate in Windows Storage » 2024-03-01 13:57:57

ty ab-

I'm a few steps further, Moving my Certiicate to MY private storage and looking for ThumbPrint now works:

  LsThumbPrint := '12097c0d0db94e85b83b415bc8b6aa324dcd9dc1';

  flags := Length(LsThumbPrint) div 2;
  SetLength(certblob, flags);
  HexToBinFast(PAnsiChar(LsThumbPrint), PByte(certblob), flags);
  blob.cbData := flags;
  blob.pbData := pointer(certblob);
  fAcceptCert := mormot.lib.sspi.CertFindCertificateInStore(fAcceptCertStore, X509_ASN_ENCODING or PKCS_7_ASN_ENCODING, 0, $10000, @blob, nil);
  if fAcceptCert = nil then
    raise ESChannel.Create('AfterBind: no Certificate available');

But if i use my request to local machine (See above) and then look for thmubprint does not work - may something wrong with selecting right storage

#50 Re: mORMot 2 » Feature request or question concerning Certificate in Windows Storage » 2024-03-01 10:25:04

ab wrote:

You need to use the TNetTlsContext fields.
My guess is that you need client TLS authentication using a certificate with a private key stored within the local windows storage?

But it depends on the TLS engine used.
For OpenSSL you can specify CertificateFile or other fields if needed.
For SSPI (default on Windows), you can't specify a client certificate (yet).

You can try to modify TSChannelNetTls in mormot.net.sock.windows.inc to add the ability to specify a client Certificate in TNetTlsContext.
Either as a file name or a file fingerprint using CertFindCertificateInStore(CERT_FIND_HASH).
If you need it for SSPI, I could try to implement it, and you may validate/test it.

Hi Arnaud, my certificate is stored in local Machine storage. so i tried to add it to SChannel Afterbind, but get error on start i can not explain to me:

procedure TSChannelNetTls.AfterBind(var Context: TNetTlsContext);
var
  certblob: RawByteString;
  blob: TCryptDataBlob;
  pass: SynUnicode;
  flags: integer;
begin
  if Context.CertificateFile = '' then begin
    // Load certificate and private key from Windows certificate store
//     fAcceptCertStore := CertOpenSystemStoreW(nil, 'MY')
    var LProvider : WideChar := WideChar(CERT_STORE_PROV_SYSTEM);
    var LMy := 'MY';
    fAcceptCertStore := mormot.lib.sspi.CertOpenStoreW(@LProvider, 0, nil, CERT_SYSTEM_STORE_LOCAL_MACHINE, @LMy);
  end else
  begin
    certblob := StringFromFile(TFileName(Context.CertificateFile));

At Programm start a message pops up CertOpenStoreW not found in dll (my exe name) in source is it declared as extern crypt32.dll

any idea ?

Board footer

Powered by FluxBB