Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Tony_Bedford

Re: Access is denied when setting DebugLogPath

martin wrote:

When setting the Session.DebugLogPath, the WinSCP .NET assembly writes only that path, and does not access anything else. Do you have a full stacktrace?


Hi Martin
I'm not sure if this is the stack trace you are referring to, but this is what I can find from .Net. I've also attached the full DebugLog files (with some redactions) that are produced when both a normal user and an admin user runs the process.

I've set these debug log files to use the Debug2 level setting, in the hope that this will yield a clue to this bizarre issue. BTW it doesn't matter which log level we use the process still fails for the normal users.

    [Lightweight Function]
    System.ServiceModel.dll!System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(object instance, object[] inputs, out object[] outputs)
    System.ServiceModel.dll!System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(ref System.ServiceModel.Dispatcher.MessageRpc rpc)
    System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(ref System.ServiceModel.Dispatcher.MessageRpc rpc)
    System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(ref System.ServiceModel.Dispatcher.MessageRpc rpc)
    System.ServiceModel.dll!System.ServiceModel.Dispatcher.MessageRpc.Process(bool isOperationContextSet)
    System.ServiceModel.dll!System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(System.ServiceModel.Channels.RequestContext request, bool cleanThread, System.ServiceModel.OperationContext currentOperationContext)
    System.ServiceModel.dll!System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(System.ServiceModel.Channels.RequestContext request, System.ServiceModel.OperationContext currentOperationContext)
    System.ServiceModel.dll!System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(System.IAsyncResult result)
    System.ServiceModel.Internals.dll!System.Runtime.ActionItem.DefaultActionItem.TraceAndInvoke()
    System.ServiceModel.Internals.dll!System.Runtime.ActionItem.CallbackHelper.InvokeWithoutContext(object state)
    System.ServiceModel.Internals.dll!System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped)
    System.ServiceModel.Internals.dll!System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(uint error, uint bytesRead, System.Threading.NativeOverlapped* nativeOverlapped)
    mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP)
    [Native to Managed Transition]
martin

Re: Access is denied when setting DebugLogPath

When setting the Session.DebugLogPath, the WinSCP .NET assembly writes only that path, and does not access anything else. Do you have a full stacktrace?
Tony_Bedford

Access is denied when setting DebugLogPath

We’ve just upgraded one of our webservices (which is on a VM Server running Windows Server 2016 that used WinSCP 5.15.7 (build 10060) to 6.5.6 (build 16502 2026-03-25) and found an interesting issue.

When the end user runs the service, they get an “Access is denied” error message being returned from the C# call. Further investigation has identified that this error is being caused by the setting of the DebugLogPath
string DebugLogfile = "D:\Logs\DebugTESTLog.txt"; 
session.DebugLogPath = DebugLogfile;

nb: filename has been changed for this post but is representative of the real values.

We know this access denied is not to do with the log file itself because the log file is written to this area for the old version and we get the start of a Debug logfile with the new version.
The last line that is recorded in this shorten log file (before the clean-up process) is:
[2026-05-11 11:08:46.938] [0008] Assembly path: C:\inetpub\wwwroot\[location of service]\WinSCPnet.DLL
[2026-05-11 11:08:46.938] [0008] Assembly product version: 6.5.6.0

But when an admin runs the process they get:
[2026-05-11 11:23:28.490] [0021] Assembly path: C:\inetpub\wwwroot\[location of service]\WinSCPnet.DLL
[2026-05-11 11:23:28.490] [0021] Assembly product version: 6.5.6.0
[2026-05-11 11:23:28.490] [0021] Process path: c:\windows\system32\inetsrv\w3wp.exe
[2026-05-11 11:23:28.490] [0021] Session.Open entering

When we compare the log file produced by the admin with a log file produced by the old version of WinSCP it is noticeable that the “Process path: c:\windows\system32\inetsrv\w3wp.exe” line is not in the older log file. From what I can tell, this file and directory has permission for everyone to read/execute so I am not sure what file/folder the access is being denied for.
So my questions are:

  1. What file/folder is WinSCP trying to access when setting the DebugLogPath that an access denied error could be produced? and what right are needed?
  2. Is there a solution to this problem that is NOT “don’t create the log files” or “giving every user who uses this service Admin rights” ?
  3. Is this is a bug within the latest version of WinSCP which is stopping non-admin users from setting/creating log files?

TIA