Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

sp_replwritetovarbin memory overwrite Security threat

 
Goto page Previous  1, 2
   Database Help (Home) -> Security RSS
Next:  Caculated Measure - Date Filter - Range  
Author Message
DBADave

External


Since: Jun 10, 2008
Posts: 6



(Msg. 16) Posted: Fri Jan 16, 2009 7:11 am
Post subject: Re: sp_replwritetovarbin memory overwrite Security threat [Login to view extended thread Info.]
Archived from groups: microsoft>public>sqlserver>security (more info?)

The only issue you may run into is that, if you are using replication with
updatable subscriptions, you will break the replication by DENYing execute on
it.

Try this to fix it:
USE master
GO


SET NOCOUNT ON;

DECLARE
@fixit BIT,
@DBName varchar(255),
@sql varchar(2000)

SET @fixit = 1

-- LIMIT THE CHECK TO DATABASE THAT ARE MARKED WITH A REPLICATION STATUS
DECLARE DBCursor CURSOR FOR
SELECT [name] FROM master..sysdatabases WHERE [category] <> 0

OPEN DBCursor
FETCH NEXT FROM DBCursor INTO @DBName

WHILE @@FETCH_STATUS = 0
BEGIN
-- CHECK THE DATABASE FOR THE EXISTENCE OF MSsubscription_agents.
-- IF THERE, QUERY THE TABLE FOR AN [update_mode] IN (4,5) -
participating in updateable subscription

-- IF PARTICIPATING, SET @fixit TO '0'
-- BUILD THE SQL STRING
SELECT @sql =
'USE ' + QUOTENAME(@DBName, '[') + ';
IF OBJECT_ID('''+ 'MSsubscription_agents' + ''') IS NOT NULL
BEGIN
IF EXISTS(SELECT [update_mode] FROM
[MSsubscription_agents] WHERE [update_mode] IN (4,5))

BEGIN
SELECT @fixit = 0
END
END'

-- EXECUTE THE STRING RETURNING @fixit

EXEC sp_executesql @sql, N'@fixit BIT OUT', @fixit OUT
FETCH NEXT FROM DBCursor INTO @DBName
END
-- CLEAN UP
CLOSE DBCursor
DEALLOCATE DBCursor

-- If the @Fixit was not set to 0, Deny the permission

IF @fixit = 1
BEGIN
PRINT 'Fix Applied'
DENY EXECUTE ON sp_replwritetovarbin TO PUBLIC
END ELSE
BEGIN
PRINT 'Updatable Subscription Found. Fix Not Applied'
END

"jaylou" wrote:

> this is true.
>
> In my spare time, I am researching what this proc is for and what needs
> acces to it.
>
> I will remove the access on a dev server and see what happens.
>
> Thanks Again,
> Joe
>
>
>
>
> "Chris Wood" wrote:
>
> > Joe,
> >
> > If you are talking SQL2005 you cannot delete it but you can take away the
> > public access to it. I would do the same on SQL2000, just stop it being
> > accessed by the public role.
> >
> > Chris
> >
> > "jaylou" wrote in message
> >
> > >I agree. I am waiting until I hear from Microsoft. I think the alert came
> > > from a third party consulting group. looking for work maybe? Smile
> > >
> > > "lmpreiki" wrote:
> > >
> > >> Even though I've searched the Microsoft website and anywhere else I can
> > >> think
> > >> of several times I haven't found anything either. I can't possibly
> > >> delete a
> > >> procedure on without knowing what impact it might have.
> > >>
> > >> "jaylou" wrote:
> > >>
> > >> > Not yet, and I still havent seen any alerts from Microsoft on this.
> > >> >
> > >> >
> > >> > "lmpreiki" wrote:
> > >> >
> > >> > > Was anyone able to identify what this proc does or what might break
> > >> > > if removed?
> > >> > >
> > >> > > Thanks,
> > >> > >
> > >> > > "jaylou" wrote:
> > >> > >
> > >> > > > I recieved an email about this procedure sp_replwritetovarbin. one
> > >> > > > recomendation is to remove it from your system.
> > >> > > >
> > >> > > > Does anyone know what this proc is for and what will break if
> > >> > > > removed?
> > >> > > >
> > >> > > > Also does anyone know if this is a real threat?
> > >> > > >
> > >> > > > TIA,
> > >> > > > Joe
> >
> >
> >

 >> Stay informed about: sp_replwritetovarbin memory overwrite Security threat 
Back to top
Login to vote
DBADave

External


Since: Jun 10, 2008
Posts: 6



(Msg. 17) Posted: Fri Jan 16, 2009 7:51 am
Post subject: RE: sp_replwritetovarbin memory overwrite Security threat [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This is primarily related to replication. If you remove it, you can break
any replication you may be running. You should DENY Execute to this stored
proc UNLESS you are running replication with Updatable Subscriptions.

Try this:
USE master
GO

SET NOCOUNT ON;

DECLARE
@fixit BIT,
@DBName varchar(255),
@sql varchar(2000)

SET @fixit = 1

-- LIMIT THE CHECK TO DATABASE THAT ARE MARKED WITH A REPLICATION STATUS
DECLARE DBCursor CURSOR FOR
SELECT [name] FROM master..sysdatabases WHERE [category] <> 0

OPEN DBCursor
FETCH NEXT FROM DBCursor INTO @DBName

WHILE @@FETCH_STATUS = 0
BEGIN
-- CHECK THE DATABASE FOR THE EXISTENCE OF MSsubscription_agents.
-- IF THERE, See if it's in an updatable subscription, If not set the
variable

SELECT @sql =
'USE ' + QUOTENAME(@DBName, '[') + ';
IF OBJECT_ID('''+ 'MSsubscription_agents' + ''') IS NOT NULL
BEGIN
IF EXISTS(SELECT [update_mode] FROM
[MSsubscription_agents] WHERE [update_mode] IN (4,5))
BEGIN
SELECT @fixit = 0
END
END'

-- EXECUTE THE STRING RETURNING @fixit
EXEC sp_executesql @sql, N'@fixit BIT OUT', @fixit OUT

FETCH NEXT FROM DBCursor INTO @DBName
END
-- CLEAN UP
CLOSE DBCursor
DEALLOCATE DBCursor

-- If the variable was not set to 0, apply the fix
IF @fixit = 1
BEGIN
PRINT 'No Updatable Subscriptions -- Applying Fix'
DENY EXECUTE ON sp_replwritetovarbin TO PUBLIC
END ELSE
BEGIN
PRINT 'Updatable Subscription - Fix not applied.'
END


"jaylou" wrote:

> I recieved an email about this procedure sp_replwritetovarbin. one
> recomendation is to remove it from your system.
>
> Does anyone know what this proc is for and what will break if removed?
>
> Also does anyone know if this is a real threat?
>
> TIA,
> Joe

 >> Stay informed about: sp_replwritetovarbin memory overwrite Security threat 
Back to top
Login to vote
Chris Wood

External


Since: Jan 22, 2008
Posts: 93



(Msg. 18) Posted: Thu Feb 05, 2009 2:13 pm
Post subject: Re: sp_replwritetovarbin memory overwrite Security threat [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

There is an SQL security bulletin expected next Tuesday. Sounds like it
might be this one.

Chris

"Chris Wood" wrote in message

> Joe,
>
> Seems that it didn't make a security bulletin this month.
>
> Chris
>
> "Chris Wood" wrote in message
>
>> Joe,
>>
>> Microsoft issued a security advisory, as expected, and it mentions that
>> they fixed it in SQL2005 SP3 so it could be in SP2 CU10 or CU11 as well.
>> See http://www.microsoft.com/technet/security/advisory/961040.mspx
>>
>> Chris
>>
>> "jaylou" wrote in message
>>
>>> Thank you again!!
>>>
>>> "Chris Wood" wrote:
>>>
>>>> Joe,
>>>>
>>>> MS just released SQL2005 SP2 CU11 and SP3 so don't be surprised that
>>>> the fix
>>>> is announced in these builds when the January patches are announced.
>>>> The
>>>> original advisory shows that MS were told about this a few months ago
>>>> so I
>>>> would expect them to have looked at SQL2000/SQL2005 and SQL2008 at that
>>>> time. They would have seen that if it was in SQL2000 that it was also
>>>> be in
>>>> SQL2005 and check out SQL2008 as well.
>>>>
>>>> Chris
>>>>
>>>> "jaylou" wrote in message
>>>>
>>>> > OK thank,
>>>> > I just subscribed to the feed.
>>>> >
>>>> > Thanks again for the info.
>>>> >
>>>> > "Chris Wood" wrote:
>>>> >
>>>> >> Joe,
>>>> >>
>>>> >> if they are serious about this I would expect a Security Advisory to
>>>> >> appear
>>>> >> here http://www.microsoft.com/technet/security/advisory/default.mspx
>>>> >> as
>>>> >> the
>>>> >> problem has been publically announced.
>>>> >>
>>>> >> Chris
>>>> >>
>>>> >> "jaylou" wrote in message
>>>> >>
>>>> >> > Yes I did. Do you know anything about this? I haven't been able
>>>> >> > to
>>>> >> > find
>>>> >> > much more then more articles pointing back to this alert.
>>>> >> >
>>>> >> > "Chris Wood" wrote:
>>>> >> >
>>>> >> >> Joe,
>>>> >> >>
>>>> >> >> You saw this alert
>>>> >> >> http://www.sec-consult.com/files/20081209_mssql-2000-sp_replwritetovar..._memwri
>>>> >> >> right?
>>>> >> >>
>>>> >> >> Chris
>>>> >> >>
>>>> >> >> "jaylou" wrote in message
>>>> >> >>
>>>> >> >> >I recieved an email about this procedure sp_replwritetovarbin.
>>>> >> >> >one
>>>> >> >> > recomendation is to remove it from your system.
>>>> >> >> >
>>>> >> >> > Does anyone know what this proc is for and what will break if
>>>> >> >> > removed?
>>>> >> >> >
>>>> >> >> > Also does anyone know if this is a real threat?
>>>> >> >> >
>>>> >> >> > TIA,
>>>> >> >> > Joe
>>>> >> >>
>>>> >> >>
>>>> >> >>
>>>> >>
>>>> >>
>>>> >>
>>>>
>>>>
>>>>
>>
>>
>
>
 >> Stay informed about: sp_replwritetovarbin memory overwrite Security threat 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Security Audit - I have problem with opening a SQL Server Logs. It takes over 5-10minutes to open the log file (Under Management->SQL Server Logs->Current). I have Audit level to log "ALL" due to SOX compliance. The errorlog files are about 19 megaby...

Integrated Security in the DMZ - I have a test web server in a domain. The IIS identity as a domain account. The website can access SQl Server (2005) using integrated security. I have a production web server in DMZ out side the domain. How can I setup the webserver to use integrated....

Record level security? - Hello, is it possible to not allow changes to certain records in a sql2k user table? We have a table that holds data for a periodic report and was wondering if it would be possible to not allow any changes/deletions to certain records that fall withi...

Security - Lock Database - I want to make some changes regarding accessing my SQL Server Database, but before I start playing around with it, I want to post something to see if anyone can give me some guidence so I don't end up locking myself out of my SQL Server Database or SQ...

ODBC Connection security - I have a need to find out when any ODBC connection is made to a certain SQL Server. I assume any/all ODBC connections will have to use TCP port 1433 - since SQL uses only TCP 1433 in this server's case. Is there any SQL method to detect a new ODBC..
   Database Help (Home) -> Security All times are: Pacific Time (US & Canada)
Goto page Previous  1, 2
Page 2 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]